home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / progtool / c / gcc / crsdoc16.zoo / doc / Termcap.doc < prev    next >
Encoding:
Text File  |  1990-03-03  |  125.4 KB  |  3,106 lines

  1. Info file: termcap,    -*-Text-*-
  2. produced by texinfo-format-buffer
  3. from file: termcap.texinfo
  4.  
  5. This file documents the termcap library of the GNU system.
  6.  
  7. Copyright (C) 1988 Free Software Foundation, Inc.
  8.  
  9. Permission is granted to make and distribute verbatim copies of
  10. this manual provided the copyright notice and this permission notice
  11. are preserved on all copies.
  12.  
  13. Permission is granted to copy and distribute modified versions of this
  14. manual under the conditions for verbatim copying, provided that the entire
  15. resulting derived work is distributed under the terms of a permission
  16. notice identical to this one.
  17.  
  18. Permission is granted to copy and distribute translations of this manual
  19. into another language, under the above conditions for modified versions,
  20. except that this permission notice may be stated in a translation approved
  21. by the Foundation.
  22.  
  23. File: termcap  Node: Top, Prev: (DIR), Up: (DIR), Next: Introduction
  24.  
  25. * Menu:
  26.  
  27. * Introduction::What is termcap?  Why this manual?
  28. * Library::     The termcap library functions.
  29. * Data Base::   What terminal descriptions in `/etc/termcap' look like.
  30. * Capabilities::Definitions of the individual terminal capabilities:
  31.                  how to write them in descriptions, and how to use
  32.                  their values to do display updating.
  33. * Var Index::   Index of C functions and variables.
  34. * Cap Index::   Index of termcap capabilities.
  35. * Index::       Concept index.
  36.  
  37.  
  38. File: termcap  Node: Introduction, Prev: Top, Up: Top, Next: Library
  39.  
  40. Introduction
  41. ************
  42.  
  43. "Termcap" is a library and data base that enables programs to use
  44. display terminals in a terminal-independent manner.  It originated in
  45. Berkeley Unix.
  46.  
  47. The termcap data base describes the capabilities of hundreds of different
  48. display terminals in great detail.  Some examples of the information
  49. recorded for a terminal could include how many columns wide it is, what
  50. string to send to move the cursor to an arbitrary position (including how
  51. to encode the row and column numbers), how to scroll the screen up one or
  52. several lines, and how much padding is needed for such a scrolling
  53. operation.
  54.  
  55. The termcap library is provided for easy access this data base in programs
  56. that want to do terminal-independent character-based display output.
  57.  
  58. This manual describes the GNU version of the termcap library, which has
  59. some extensions over the Unix version.  All the extensions are identified
  60. as such, so this manual also tells you how to use the Unix termcap.
  61.  
  62. The GNU version of the termcap library is available free as source code,
  63. for use in free programs, and runs on Unix and VMS systems (at least).  You
  64. can find it in the GNU Emacs distribution in the files `termcap.c' and
  65. `tparam.c'.
  66.  
  67. This manual was written for the GNU project, whose goal is to develop a
  68. complete free operating system upward-compatible with Unix for user
  69. programs.  The project is approximately two thirds complete.  For more
  70. information on the GNU project, including the GNU Emacs editor and the
  71. mostly-portable optimizing C compiler, send one dollar to
  72.  
  73.      Free Software Foundation
  74.      675 Mass Ave
  75.      Cambridge, MA 02139
  76.  
  77.  
  78. File: termcap  Node: Library, Prev: Top, Up: Top, Next: Data Base
  79.  
  80. The Termcap Library
  81. *******************
  82.  
  83. The termcap library is the application programmer's interface to the
  84. termcap data base.  It contains functions for the following purposes:
  85.  
  86.    * Finding the description of the user's terminal type (`tgetent').
  87.  
  88.    * Interrogating the description for information on various topics
  89.      (`tgetnum', `tgetflag', `tgetstr').
  90.  
  91.    * Computing and performing padding (`tputs').
  92.  
  93.    * Encoding numeric parameters such as cursor positions into the
  94.      terminal-specific form required for display commands (`tparam',
  95.      `tgoto').
  96.  
  97. * Menu:
  98.  
  99. * Preparation:: Preparing to use the termcap library.
  100. * Find::        Finding the description of the terminal being used.
  101. * Interrogate:: Interrogating the description for particular capabilities.
  102. * Initialize::  Initialization for output using termcap.
  103. * Padding::     Outputting padding.
  104. * Parameters::  Encoding parameters such as cursor positions.
  105.  
  106.  
  107. File: termcap  Node: Preparation, Prev: Library, Up: Library, Next: Find
  108.  
  109. Preparing to Use the Termcap Library
  110. ====================================
  111.  
  112. To use the termcap library in a program, you need two kinds of preparation:
  113.  
  114.    * The compiler needs declarations of the functions and variables in the
  115.      library.
  116.  
  117.      On GNU systems, it suffices to include the header file `termcap.h'
  118.      in each source file that uses these functions and variables.
  119.  
  120.      On Unix systems, there is often no such header file.  Then you must
  121.      explictly declare the variables as external.  You can do likewise for
  122.      the functions, or let them be implicitly declared and cast their
  123.      values from type `int' to the appropriate type.
  124.  
  125.      We illustrate the declarations of the individual termcap library
  126.      functions with ANSI C prototypes because they show how to pass the
  127.      arguments.  If you are not using the GNU C compiler, you probably
  128.      cannot use function prototypes, so omit the argument types and names
  129.      from your declarations.
  130.  
  131.    * The linker needs to search the library.  Usually either `-ltermcap'
  132.      or `-ltermlib' as an argument when linking will do this.
  133.  
  134.  
  135. File: termcap  Node: Find, Prev: Preparation, Up: Library, Next: Interrogate
  136.  
  137. Finding a Terminal Description: `tgetent'
  138. =========================================
  139.  
  140. An application program that is going to use termcap must first look up the
  141. description of the terminal type in use.  This is done by calling
  142. `tgetent', whose declaration in ANSI Standard C looks like:
  143.  
  144.      int tgetent (char *BUFFER, char *TERMTYPE);
  145.  
  146. This function finds the description and remembers it internally so that
  147. you can interrogate it about specific terminal capabilities
  148. (*Note Interrogate::).
  149.  
  150. The argument TERMTYPE is a string which is the name for the type of
  151. terminal to look up.  Usually you would obtain this from the environment
  152. variable `TERM' using `getenv ("TERM")'.
  153.  
  154. If you are using the GNU version of termcap, you can alternatively ask
  155. `tgetent' to allocate enough space.  Pass a null pointer for BUFFER, and
  156. `tgetent' itself allocates the storage using `malloc'.  In this case the
  157. returned value on success is the address of the storage, cast to `int'.
  158. But normally there is no need for you to look at the address.  Do not
  159. free the storage yourself.
  160.  
  161. With the Unix version of termcap, you must allocate space for the
  162. description yourself and pass the address of the space as the argument
  163. BUFFER.  There is no way you can tell how much space is needed, so
  164. the convention is to allocate a buffer 2048 characters long and assume that
  165. is enough.  (Formerly the convention was to allocate 1024 characters and
  166. assume that was enough.  But one day, for one kind of terminal, that was
  167. not enough.)
  168.  
  169. No matter how the space to store the description has been obtained,
  170. termcap records its address internally for use when you later
  171. interrogate the description with `tgetnum', `tgetstr' or `tgetflag'.  If
  172. the buffer was allocated by termcap, it will be freed by termcap too if
  173. you call `tgetent' again.  If the buffer was provided by you, you must
  174. make sure that its contents remain unchanged for as long as you still
  175. plan to interrogate the description.
  176.  
  177. The return value of `tgetent' is -1 if there is some difficulty
  178. accessing the data base of terminal types, 0 if the data base is accessible
  179. but the specified type is not defined in it, and some other value
  180. otherwise.
  181.  
  182. Here is how you might use the function `tgetent':
  183.  
  184.      #ifdef unix
  185.      static char term_buffer[2048];
  186.      #else
  187.      #define term_buffer 0
  188.      #endif
  189.  
  190.      init_terminal_data ()
  191.      {
  192.        char *termtype = getenv ("TERM");
  193.        int success;
  194.  
  195.        if (termtype == 0)
  196.          fatal ("Specify a terminal type with `setenv TERM <yourtype>'.\n");
  197.  
  198.        success = tgetent (term_buffer, termtype);
  199.        if (success < 0)
  200.          fatal ("Could not access the termcap data base.\n");
  201.        if (success == 0)
  202.          fatal ("Terminal type `%s' is not defined.\n", termtype);
  203.      }
  204.  
  205. Here we assume the function `fatal' prints an error message and exits.
  206.  
  207. If the environment variable `TERMCAP' is defined, its value is used to
  208. override the terminal type data base.  The function `tgetent' checks the
  209. value of `TERMCAP' automatically.  If the value starts with `/' then it
  210. is taken as a file name to use as the data base file, instead of
  211. `/etc/termcap' which is the standard data base.  If the value does not
  212. start with `/' then it is itself used as the terminal description,
  213. provided that the terminal type TERMTYPE is among the types it claims to
  214. apply to.  *Note Data Base::, for information on the format of a
  215. terminal description.
  216.  
  217.  
  218. File: termcap  Node: Interrogate, Prev: Find, Up: Library, Next: Initialize
  219.  
  220. Interrogating the Terminal Description
  221. ======================================
  222.  
  223. Each piece of information recorded in a terminal description is called a
  224. "capability".  Each defined terminal capability has a two-letter code
  225. name and a specific meaning.  For example, the number of columns is named
  226. `co'.  *Note Capabilities::, for definitions of all the standard
  227. capability names.
  228.  
  229. Once you have found the proper terminal description with `tgetent'
  230. (*Note Find::), your application program must "interrogate" it for
  231. various terminal capabilities.  You must specify the two-letter code of
  232. the capability whose value you seek.
  233.  
  234. Capability values can be numeric, boolean (capability is either present
  235. or absent) or strings.  Any particular capability always has the same
  236. value type; for example, `co' always has a numeric value, while `am'
  237. (automatic wrap at margin) is always a flag, and `cm' (cursor motion
  238. command) always has a string value.  The documentation of each
  239. capability says which type of value it has.
  240.  
  241. There are three functions to use to get the value of a capability,
  242. depending on the type of value the capability has.  Here are their
  243. declarations in ANSI C:
  244.  
  245.      int tgetnum (char *NAME);
  246.      int tgetflag (char *NAME);
  247.      char *tgetstr (char *NAME, char **AREA);
  248.  
  249. `tgetnum'
  250.      Use `tgetnum' to get a capability value that is numeric.  The
  251.      argument NAME is the two-letter code name of the capability.  If
  252.      the capability is present, `tgetnum' returns the numeric value
  253.      (which is nonnegative).  If the capability is not mentioned in the
  254.      terminal description, `tgetnum' returns -1.
  255.  
  256. `tgetflag'
  257.      Use `tgetflag' to get a boolean value.  If the capability
  258.      NAME is present in the terminal description, `tgetflag'
  259.      returns 1; otherwise, it returns 0.
  260.  
  261. `tgetstr'
  262.      Use `tgetstr' to get a string value.  It returns a pointer to a
  263.      string which is the capability value, or a null pointer if the
  264.      capability is not present in the terminal description.
  265.  
  266.      There are two ways `tgetstr' can find space to store the string value:
  267.  
  268.         * You can ask `tgetstr' to allocate the space.  Pass a null
  269.           pointer for the argument AREA, and `tgetstr' will use
  270.           `malloc' to allocate storage big enough for the value.
  271.           Termcap will never free this storage or refer to it again; you
  272.           should free it when you are finished with it.
  273.  
  274.           This method is more robust, since there is no need to guess how
  275.           much space is needed.  But it is supported only by the GNU
  276.           termcap library.
  277.  
  278.         * You can provide the space.  Provide for the argument AREA the
  279.           address of a pointer variable of type `char *'.  Before calling
  280.           `tgetstr', initialize the variable to point at available space.
  281.           Then `tgetstr' will store the string value in that space and will
  282.           increment the pointer variable to point after the space that has been
  283.           used.  You can use the same pointer variable for many calls to
  284.           `tgetstr'.
  285.  
  286.           There is no way to determine how much space is needed for a single
  287.           string, and no way for you to prevent or handle overflow of the area
  288.           you have provided.  However, you can be sure that the total size of
  289.           all the string values you will obtain from the terminal description is
  290.           no greater than the size of the description (unless you get the same
  291.           capability twice).  You can determine that size with `strlen' on
  292.           the buffer you provided to `tgetent'.  See below for an example.
  293.  
  294.           Providing the space yourself is the only method supported by the Unix
  295.           version of termcap.
  296.  
  297. Note that you do not have to specify a terminal type or terminal
  298. description for the interrogation functions.  They automatically use the
  299. description found by the most recent call to `tgetent'.
  300.  
  301. Here is an example of interrogating a terminal description for various
  302. capabilities, with conditionals to select between the Unix and GNU methods
  303. of providing buffer space.
  304.  
  305.      char *tgetstr ();
  306.  
  307.      char *cl_string, *cm_string;
  308.      int height;
  309.      int width;
  310.      int auto_wrap;
  311.  
  312.      char PC;   /* For tputs.  */
  313.      char *BC;  /* For tgoto.  */
  314.      char *UP;
  315.  
  316.      interrogate_terminal ()
  317.      {
  318.      #ifdef UNIX
  319.        /* Here we assume that an explicit term_buffer
  320.           was provided to tgetent.  */
  321.        char *buffer
  322.          = (char *) malloc (strlen (term_buffer));
  323.      #define BUFFADDR &buffer
  324.      #else
  325.      #define BUFFADDR 0
  326.      #endif
  327.  
  328.        char *temp;
  329.  
  330.        /* Extract information we will use.  */
  331.        cl_string = tgetstr ("cl", BUFFADDR);
  332.        cm_string = tgetstr ("cm", BUFFADDR);
  333.        auto_wrap = tgetflag ("am");
  334.        height = tgetnum ("li");
  335.        width = tgetnum ("co");
  336.  
  337.        /* Extract information that termcap functions use.  */
  338.        temp = tgetstr ("pc", BUFFADDR);
  339.        PC = temp ? *temp : 0;
  340.        BC = tgetstr ("le", BUFFADDR);
  341.        UP = tgetstr ("up", BUFFADDR);
  342.      }
  343.  
  344. *Note Padding::, for information on the variable `PC'.  *Note Using Parameters::, for information on `UP' and `BC'.
  345.  
  346.  
  347. File: termcap  Node: Initialize, Prev: Interrogate, Up: Library, Next: Padding
  348.  
  349. Initialization for Use of Termcap
  350. =================================
  351.  
  352. Before starting to output commands to a terminal using termcap,
  353. an application program should do two things:
  354.  
  355.    * Initialize various global variables which termcap library output
  356.      functions refer to.  These include `PC' and `ospeed' for padding
  357.      (*Note Output Padding::) and `UP' and `BC' for cursor motion (*Note
  358.      tgoto::).
  359.  
  360.    * Tell the kernel to turn off alteration and padding of horizontal-tab
  361.      characters sent to the terminal.
  362.  
  363. To turn off output processing in Berkeley Unix you would use `ioctl'
  364. with code `TIOCLSET' to set the bit named `LLITOUT', and clear the bits
  365. `ANYDELAY' using `TIOCSETN'.  In POSIX or System V, you must clear the
  366. bit named `OPOST'.  Refer to the system documentation for details.
  367.  
  368. If you do not set the terminal flags properly, some older terminals will
  369. not work.  This is because their commands may contain the characters that
  370. normally signify newline, carriage return and horizontal tab---characters
  371. which the kernel thinks it ought to modify before output.
  372.  
  373. When you change the kernel's terminal flags, you must arrange to restore
  374. them to their normal state when your program exits.  This implies that the
  375. program must catch fatal signals such as `SIGQUIT' and `SIGINT'
  376. and restore the old terminal flags before actually terminating.
  377.  
  378. Modern terminals' commands do not use these special characters, so if you
  379. do not care about problems with old terminals, you can leave the kernel's
  380. terminal flags unaltered.
  381.  
  382.  
  383. File: termcap  Node: Padding, Prev: Initialize, Up: Library, Next: Parameters
  384.  
  385. Padding
  386. =======
  387.  
  388. "Padding" means outputting null characters following a terminal display
  389. command that takes a long time to execute.  The terminal description says
  390. which commands require padding and how much; the function `tputs',
  391. described below, outputs a terminal command while extracting from it the
  392. padding information, and then outputs the padding that is necessary.
  393.  
  394. * Menu:
  395.  
  396. * Why Pad::          Explanation of padding.
  397. * Describe Padding:: The data base says how much padding a terminal needs.
  398. * Output Padding::   Using `tputs' to output the needed padding.
  399.  
  400.  
  401. File: termcap  Node: Why Pad, Prev: Padding, Up: Padding, Next: Describe Padding
  402.  
  403. Why Pad, and How
  404. ----------------
  405.  
  406. Most types of terminal have commands that take longer to execute than they
  407. do to send over a high-speed line.  For example, clearing the screen may
  408. take 20msec once the entire command is received.  During that time, on a
  409. 9600 bps line, the terminal could receive about 20 additional output
  410. characters while still busy clearing the screen.  Every terminal has a
  411. certain amount of buffering capacity to remember output characters that
  412. cannot be processed yet, but too many slow commands in a row can cause the
  413. buffer to fill up.  Then any additional output that cannot be processed
  414. immediately will be lost.
  415.  
  416. To avoid this problem, we normally follow each display command with enough
  417. useless charaters (usually null characters) to fill up the time that the
  418. display command needs to execute.  This does the job if the terminal throws
  419. away null characters without using up space in the buffer (which most
  420. terminals do).  If enough padding is used, no output can ever be lost.  The
  421. right amount of padding avoids loss of output without slowing down
  422. operation, since the time used to transmit padding is time that nothing
  423. else could be done.
  424.  
  425. The number of padding characters needed for an operation depends on the
  426. line speed.  In fact, it is proportional to the line speed.  A 9600 baud
  427. line transmits about one character per msec, so the clear screen command in
  428. the example above would need about 20 characters of padding.  At 1200 baud,
  429. however, only about 3 characters of padding are needed to fill up 20msec.
  430.  
  431.  
  432. File: termcap  Node: Describe Padding, Prev: Why Pad, Up: Padding, Next: Output Padding
  433.  
  434. Specifying Padding in a Terminal Description
  435. --------------------------------------------
  436.  
  437. In the terminal description, the amount of padding required by each display
  438. command is recorded as a sequence of digits at the front of the command.
  439. These digits specify the padding time in msec.  They can be followed
  440. optionally by a decimal point and one more digit, which is a number of
  441. tenths of msec.
  442.  
  443. Sometimes the padding needed by a command depends on the cursor position.
  444. For example, the time taken by an "insert line" command is usually
  445. proportional to the number of lines that need to be moved down or cleared.
  446. An asterisk (`*') following the padding time says that the time
  447. should be multiplied by the number of screen lines affected by the command.
  448.  
  449.      :al=1.3*\E[L:
  450.  
  451. is used to describe the "insert line" command for a certain terminal.
  452. The padding required is 1.3 msec per line affected.  The command itself is
  453. `ESC [ L'.
  454.  
  455. The padding time specified in this way tells `tputs' how many pad
  456. characters to output.  *Note Output Padding::.
  457.  
  458. Two special capability values affect padding for all commands.  These are
  459. the `pc' and `pb'.  The variable `pc' specifies the
  460. character to pad with, and `pb' the speed below which no padding is
  461. needed.  The defaults for these variables, a null character and 0,
  462. are correct for most terminals.  *Note Pad Specs::.
  463.  
  464.  
  465. File: termcap  Node: Output Padding, Prev: Describe Padding, Up: Padding
  466.  
  467. Performing Padding with `tputs'
  468. -------------------------------
  469.  
  470. Use the termcap function `tputs' to output a string containing an
  471. optional padding spec of the form described above (*Note Describe Padding::).  The function `tputs' strips off and decodes the padding
  472. spec, outputs the rest of the string, and then outputs the appropriate
  473. padding.  Here is its declaration in ANSI C:
  474.  
  475.      char PC;
  476.      short ospeed;
  477.  
  478.      int tputs (char *STRING, int NLINES, int (*OUTFUN) ());
  479.  
  480. Here STRING is the string (including padding spec) to be output;
  481. NLINES is the number of lines affected by the operation, which is
  482. used to multiply the amount of padding if the padding spec ends with a
  483. `*'.  Finally, OUTFUN is a function (such as `fputchar')
  484. that is called to output each character.  When actually called,
  485. OUTFUN should expect one argument, a character.
  486.  
  487. The operation of `tputs' is controlled by two global variables,
  488. `ospeed' and `PC'.  The value of `ospeed' is supposed to be
  489. the terminal output speed, encoded as in the `ioctl' system call which
  490. gets the speed information.  This is needed to compute the number of
  491. padding characters.  The value of `PC' is the character used for
  492. padding.
  493.  
  494. You are responsible for storing suitable values into these variables
  495. before using `tputs'.  The value stored into the `PC' variable should be
  496. taken from the `pc' capability in the terminal description (*Note Pad
  497. Specs::).  Store zero in `PC' if there is no `pc' capability.
  498.  
  499. The argument NLINES requires some thought.  Normally, it should be the
  500. number of lines whose contents will be cleared or moved by the command.
  501. For cursor motion commands, or commands that do editing within one line,
  502. use the value 1.  For most commands that affect multiple lines, such as
  503. `al' (insert a line) and `cd' (clear from the cursor to the end of the
  504. screen), NLINES should be the screen height minus the current vertical
  505. position (origin 0).  For multiple insert and scroll commands such as
  506. `AL' (insert multiple lines), that same value for NLINES is correct; the
  507. number of lines being inserted is not correct.
  508.  
  509. If a "scroll window" feature is used to reduce the number of lines
  510. affected by a command, the value of NLINES should take this into
  511. account.  This is because the delay time required depends on how much work
  512. the terminal has to do, and the scroll window feature reduces the work.
  513. *Note Scrolling::.
  514.  
  515. Commands such as `ic' and `dc' (insert or delete characters) are
  516. problematical because the padding needed by these commands is proportional
  517. to the number of characters affected, which is the number of columns from
  518. the cursor to the end of the line.  It would be nice to have a way to
  519. specify such a dependence, and there is no need for dependence on vertical
  520. position in these commands, so it is an obvious idea to say that for these
  521. commands NLINES should really be the number of columns affected.
  522. However, the definition of termcap clearly says that NLINES is always
  523. the number of lines affected, even in this case, where it is always 1.  It
  524. is not easy to change this rule now, because too many programs and terminal
  525. descriptions have been written to follow it.
  526.  
  527. Because NLINES is always 1 for the `ic' and `dc' strings,
  528. there is no reason for them to use `*', but some of them do.  These
  529. should be corrected by deleting the `*'.  If, some day, such entries
  530. have disappeared, it may be possible to change to a more useful convention
  531. for the NLINES argument for these operations without breaking any
  532. programs.
  533.  
  534.  
  535. File: termcap  Node: Parameters, Prev: Padding, Up: Library
  536.  
  537. Filling In Parameters
  538. =====================
  539.  
  540. Some terminal control strings require numeric "parameters".  For
  541. example, when you move the cursor, you need to say what horizontal and
  542. vertical positions to move it to.  The value of the terminal's `cm'
  543. capability, which says how to move the cursor, cannot simply be a string of
  544. characters; it must say how to express the cursor position numbers and
  545. where to put them within the command.
  546.  
  547. The specifications of termcap include conventions as to which string-valued
  548. capabilities require parameters, how many parameters, and what the
  549. parameters mean; for example, it defines the `cm' string to take
  550. two parameters, the vertical and horizontal positions, with 0,0 being the
  551. upper left corner.  These conventions are described where the individual
  552. commands are documented.
  553.  
  554. Termcap also defines a language used within the capability definition for
  555. specifying how and where to encode the parameters for output.  This language
  556. uses character sequences starting with `%'.  (This is the same idea as
  557. `printf', but the details are different.)  The language for parameter
  558. encoding is described in this section.
  559.  
  560. A program that is doing display output calls the functions `tparam' or
  561. `tgoto' to encode parameters according to the specifications.  These
  562. functions produce a string containing the actual commands to be output (as
  563. well a padding spec which must be processed with `tputs';
  564. *Note Padding::).
  565.  
  566. * Menu:
  567.  
  568. * Encode Parameters:: The language for encoding parameters.
  569. * Using Parameters::  Outputting a string command with parameters.
  570.  
  571.  
  572. File: termcap  Node: Encode Parameters, Prev: Parameters, Up: Parameters, Next: Using Parameters
  573.  
  574. Describing the Encoding
  575. -----------------------
  576.  
  577. A terminal command string that requires parameters contains special
  578. character sequences starting with `%' to say how to encode the
  579. parameters.  These sequences control the actions of `tparam' and
  580. `tgoto'.
  581.  
  582. The parameters values passed to `tparam' or `tgoto' are
  583. considered to form a vector.  A pointer into this vector determines
  584. the next parameter to be processed.  Some of the `%'-sequences
  585. encode one parameter and advance the pointer to the next parameter.
  586. Other `%'-sequences alter the pointer or alter the parameter
  587. values without generating output.
  588.  
  589. For example, the `cm' string for a standard ANSI terminal is written
  590. as `\E[%i%d;%dH'.  (`\E' stands for ESC.)  `cm' by
  591. convention always requires two parameters, the vertical and horizontal goal
  592. positions, so this string specifies the encoding of two parameters.  Here
  593. `%i' increments the two values supplied, and each `%d' encodes
  594. one of the values in decimal.  If the cursor position values 20,58 are
  595. encoded with this string, the result is `\E[21;59H'.
  596.  
  597. First, here are the `%'-sequences that generate output.  Except for
  598. `%%', each of them encodes one parameter and advances the pointer
  599. to the following parameter.
  600.  
  601. `%%'
  602.      Output a single `%'.  This is the only way to represent a literal
  603.      `%' in a terminal command with parameters.  `%%' does not
  604.      use up a parameter.
  605.  
  606. `%d'
  607.      As in `printf', output the next parameter in decimal.
  608.  
  609. `%2'
  610.      Like `%02d' in `printf': output the next parameter in
  611.      decimal, and always use at least two digits.
  612.  
  613. `%3'
  614.      Like `%03d' in `printf': output the next parameter in
  615.      decimal, and always use at least three digits.  Note that `%4'
  616.      and so on are *not* defined.
  617.  
  618. `%.'
  619.      Output the next parameter as a single character whose ASCII code is
  620.      the parameter value.  Like `%c' in `printf'.
  621.  
  622. `%+CHAR'
  623.      Add the next parameter to the character CHAR, and output the
  624.      resulting character.  For example, `%+ ' represents 0 as a space,
  625.      1 as `!', etc.
  626.  
  627. The following `%'-sequences specify alteration of the parameters (their
  628. values, or their order) rather than encoding a parameter for output.
  629. They generate no output; they are used only for their side effects on
  630. the parameters.  Also, they do not advance the "next parameter" pointer
  631. except as explicitly stated.  Only `%i', `%r' and `%>' are defined in
  632. standard Unix termcap.  The others are GNU extensions.
  633.  
  634. `%i'
  635.      Increment the next two parameters.  This is used for terminals that
  636.      expect cursor positions in origin 1.  For example, `%i%d,%d' would
  637.      output two parameters with `1' for 0, `2' for 1, etc.
  638.  
  639. `%r'
  640.      Interchange the next two parameters.  This is used for terminals whose
  641.      cursor positioning command expects the horizontal position first.
  642.  
  643. `%s'
  644.      Skip the next parameter.  Do not output anything.
  645.  
  646. `%b'
  647.      Back up one parameter.  The last parameter used will become once again
  648.      the next parameter to be output, and the next output command will use
  649.      it.  Using `%b' more than once, you can back up any number of
  650.      parameters, and you can refer to each parameter any number of times.
  651.  
  652. `%>C1C2'
  653.      Conditionally increment the next parameter.  Here C1 and C2 are
  654.      characters which stand for their ASCII codes as numbers.  If the
  655.      next parameter is greater than the ASCII code of C1, the ASCII code
  656.      of C2 is added to it.
  657.  
  658. `%a OP TYPE POS'
  659.      Perform arithmetic on the next parameter, do not use it up, and do not
  660.      output anything.  Here OP specifies the arithmetic operation,
  661.      while TYPE and POS together specify the other operand.
  662.  
  663.      Spaces are used above to separate the operands for clarity; the spaces
  664.      don't appear in the data base, where this sequence is exactly five
  665.      characters long.
  666.  
  667.      The character OP says what kind of arithmetic operation to
  668.      perform.  It can be any of these characters:
  669.  
  670.      `='
  671.           assign a value to the next parameter, ignoring its old value.
  672.           The new value comes from the other operand.
  673.  
  674.      `+'
  675.           add the other operand to the next parameter.
  676.  
  677.      `-'
  678.           subtract the other operand from the next parameter.
  679.  
  680.      `*'
  681.           multiply the next parameter by the other operand.
  682.  
  683.      `/'
  684.           divide the next parameter by the other operand.
  685.  
  686.      The "other operand" may be another parameter's value or a constant;
  687.      the character TYPE says which.  It can be:
  688.  
  689.      `p'
  690.           Use another parameter.  The character POS says which
  691.           parameter to use.  Subtract 64 from its ASCII code to get the
  692.           position of the desired parameter relative to this one.  Thus,
  693.           the character `A' as POS means the parameter after the
  694.           next one; the character `?' means the parameter before the
  695.           next one.
  696.  
  697.      `c'
  698.           Use a constant value.  The character POS specifies the
  699.           value of the constant.  The 0200 bit is cleared out, so that 0200
  700.           can be used to represent zero.
  701.  
  702. The following `%'-sequences are special purpose hacks to compensate
  703. for the weird designs of obscure terminals.  They modify the next parameter
  704. or the next two parameters but do not generate output and do not use up any
  705. parameters.  `%m' is a GNU extension; the others are defined in
  706. standard Unix termcap.
  707.  
  708. `%n'
  709.      Exclusive-or the next parameter with 0140, and likewise the parameter
  710.      after next.
  711.  
  712. `%m'
  713.      Complement all the bits of the next parameter and the parameter after next.
  714.  
  715. `%B'
  716.      Encode the next parameter in BCD.  It alters the value of the
  717.      parameter by adding six times the quotient of the parameter by ten.
  718.      Here is a C statement that shows how the new value is computed:
  719.  
  720.           PARM = (PARM / 10) * 16 + PARM % 10;
  721.  
  722. `%D'
  723.      Transform the next parameter as needed by Delta Data terminals.
  724.      This involves subtracting twice the remainder of the parameter by 16.
  725.  
  726.           PARM -= 2 * (PARM % 16);
  727.  
  728.  
  729. File: termcap  Node: Using Parameters, Prev: Encode Parameters, Up: Parameters
  730.  
  731. Sending Display Commands with Parameters
  732. ----------------------------------------
  733.  
  734. The termcap library functions `tparam' and `tgoto' serve as the
  735. analog of `printf' for terminal string parameters.  The newer function
  736. `tparam' is a GNU extension, more general but missing from Unix
  737. termcap.  The original parameter-encoding function is `tgoto', which
  738. is preferable for cursor motion.
  739.  
  740. * Menu:
  741.  
  742. * tparam::   The general case, for GNU termcap only.
  743. * tgoto::    The special case of cursor motion.
  744.  
  745.  
  746. File: termcap  Node: tparam, Prev: Using Parameters, Up: Using Parameters, Next: tgoto
  747.  
  748. `tparam'
  749. ........
  750.  
  751. The function `tparam' can encode display commands with any number of
  752. parameters and allows you to specify the buffer space.  It is the preferred
  753. function for encoding parameters for all but the `cm' capability.  Its
  754. ANSI C declaration is as follows:
  755.  
  756.      char *tparam (char *CTLSTRING, char *BUFFER, int SIZE, int PARM1,...)
  757.  
  758. The arguments are a control string CTLSTRING (the value of a terminal
  759. capability, presumably), an output buffer BUFFER and SIZE, and
  760. any number of integer parameters to be encoded.  The effect of
  761. `tparam' is to copy the control string into the buffer, encoding
  762. parameters according to the `%' sequences in the control string.
  763.  
  764. You describe the output buffer by its address, BUFFER, and its size
  765. in bytes, SIZE.  If the buffer is not big enough for the data to be
  766. stored in it, `tparam' calls `malloc' to get a larger buffer.  In
  767. either case, `tparam' returns the address of the buffer it ultimately
  768. uses.  If the value equals BUFFER, your original buffer was used.
  769. Otherwise, a new buffer was allocated, and you must free it after you are
  770. done with printing the results.  If you pass zero for SIZE and
  771. BUFFER, `tparam' always allocates the space with `malloc'.
  772.  
  773. All capabilities that require parameters also have the ability to specify
  774. padding, so you should use `tputs' to output the string produced by
  775. `tparam'.  *Note Padding::.  Here is an example.
  776.  
  777.      {
  778.        char *buf;
  779.        char buffer[40];
  780.  
  781.        buf = tparam (command, buffer, 40, parm);
  782.        tputs (buf, 1, fputchar);
  783.        if (buf != buffer)
  784.          free (buf);
  785.      }
  786.  
  787. If a parameter whose value is zero is encoded with `%.'-style encoding,
  788. the result is a null character, which will confuse `tputs'.  This would
  789. be a serious problem, but luckily `%.' encoding is used only by a few
  790. old models of terminal, and only for the `cm' capability.  To solve the
  791. problem, use `tgoto' rather than `tparam' to encode the `cm' capability.
  792.  
  793.  
  794. File: termcap  Node: tgoto, Prev: tparam, Up: Using Parameters
  795.  
  796. `tgoto'
  797. .......
  798.  
  799. The special case of cursor motion is handled by `tgoto'.  There
  800. are two reasons why you might choose to use `tgoto':
  801.  
  802.    * For Unix compatibility, because Unix termcap does not have `tparam'.
  803.  
  804.    * For the `cm' capability, since `tgoto' has a special feature
  805.      to avoid problems with null characters, tabs and newlines on certain old
  806.      terminal types that use `%.' encoding for that capability.
  807.  
  808. Here is how `tgoto' might be declared in ANSI C:
  809.  
  810.      char *tgoto (char *CSTRING, int HPOS, int VPOS)
  811.  
  812. There are three arguments, the terminal description's `cm' string and
  813. the two cursor position numbers; `tgoto' computes the parametrized
  814. string in an internal static buffer and returns the address of that buffer.
  815. The next time you use `tgoto' the same buffer will be reused.
  816.  
  817. Parameters encoded with `%.' encoding can generate null characters,
  818. tabs or newlines.  These might cause trouble: the null character because
  819. `tputs' would think that was the end of the string, the tab because
  820. the kernel or other software might expand it into spaces, and the newline
  821. becaue the kernel might add a carriage-return, or padding characters
  822. normally used for a newline.  To prevent such problems, `tgoto' is
  823. careful to avoid these characters.  Here is how this works: if the target
  824. cursor position value is such as to cause a problem (that is to say, zero,
  825. nine or ten), `tgoto' increments it by one, then compensates by
  826. appending a string to move the cursor back or up one position.
  827.  
  828. The compensation strings to use for moving back or up are found in global
  829. variables named `BC' and `UP'.  These are actual external C
  830. variables with upper case names; they are declared `char *'.  It is up
  831. to you to store suitable values in them, normally obtained from the
  832. `le' and `up' terminal capabilities in the terminal description
  833. with `tgetstr'.  Alternatively, if these two variables are both zero,
  834. the feature of avoiding nulls, tabs and newlines is turned off.
  835.  
  836. It is safe to use `tgoto' for commands other than `cm' only if
  837. you have stored zero in `BC' and `UP'.
  838.  
  839. Note that `tgoto' reverses the order of its operands: the horizontal
  840. position comes before the vertical position in the arguments to `tgoto',
  841. even though the vertical position comes before the horizontal in the
  842. parameters of the `cm' string.  If you use `tgoto' with a command such
  843. as `AL' that takes one parameter, you must pass the parameter to `tgoto'
  844. as the "vertical position".
  845.  
  846.  
  847. File: termcap  Node: Data Base, Prev: Library, Up: Top, Next: Capabilities
  848.  
  849. The Format of the Data Base
  850. ***************************
  851.  
  852. The termcap data base of terminal descriptions is stored in the file
  853. `/etc/termcap'.  It contains terminal descriptions, blank lines, and
  854. comments.
  855.  
  856. A terminal description starts with one or more names for the terminal type.
  857. The information in the description is a series of "capability names"
  858. and values.  The capability names have standard meanings
  859. (*Note Capabilities::) and their values describe the terminal.
  860.  
  861. * Menu:
  862.  
  863. * Format::            Overall format of a terminal description.
  864. * Capability Format:: Format of capabilities within a description.
  865. * Naming::            Naming conventions for terminal types.
  866. * Inheriting::        Inheriting part of a description from
  867.                         a related terminal type.
  868.  
  869.  
  870. File: termcap  Node: Format, Prev: Data Base, Up: Data Base, Next: Capability Format
  871.  
  872. Terminal Description Format
  873. ===========================
  874.  
  875. Aside from comments (lines starting with `#', which are ignored), each
  876. nonblank line in the termcap data base is a terminal description.
  877. A terminal description is nominally a single line, but it can be split
  878. into multiple lines by inserting the two characters `\ newline'.
  879. This sequence is ignored wherever it appears in a description.
  880.  
  881. The preferred way to split the description is between capabilities: insert
  882. the four characters `: \ newline tab' immediately before any colon.
  883. This allows each sub-line to start with some indentation.  This works
  884. because, after the `\ newline' are ignored, the result is `: tab
  885. :'; the first colon ends the preceding capability and the second colon
  886. starts the next capability.  If you split with `\ newline' alone, you
  887. may not add any indentation after them.
  888.  
  889. Here is a real example of a terminal description:
  890.  
  891.      dw|vt52|DEC vt52:\
  892.              :cr=^M:do=^J:nl=^J:bl=^G:\
  893.              :le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:cm=\EY%+ %+ :co#80:li#24:\
  894.              :nd=\EC:ta=^I:pt:sr=\EI:up=\EA:\
  895.              :ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H:
  896.  
  897. Each terminal description begins with several names for the terminal type.
  898. The names are separated by `|' characters, and a colon ends the last
  899. name.  The first name should be two characters long; it exists only for the
  900. sake of very old Unix systems and is never used in modern systems.  The
  901. last name should be a fully verbose name such as "DEC vt52" or "Ann
  902. Arbor Ambassador with 48 lines".  The other names should include whatever
  903. the user ought to be able to specify to get this terminal type, such as
  904. `vt52' or `aaa-48'.  *Note Naming::, for information on how to
  905. choose terminal type names.
  906.  
  907. After the terminal type names come the terminal capabilities, separated by
  908. colons and with a colon after the last one.  Each capability has a
  909. two-letter name, such as `cm' for "cursor motion string" or `li'
  910. for "number of display lines".
  911.  
  912.  
  913. File: termcap  Node: Capability Format, Prev: Format, Up: Data Base, Next: Naming
  914.  
  915. Writing the Capabilities
  916. ========================
  917.  
  918. There are three kinds of capabilities: flags, numbers, and strings.  Each
  919. kind has its own way of being written in the description.  Each defined
  920. capability has by convention a particular kind of value; for example,
  921. `li' always has a numeric value and `cm' always a string value.
  922.  
  923. A flag capability is thought of as having a boolean value: the value is
  924. true if the capability is present, false if not.  When the capability is
  925. present, just write its name between two colons.
  926.  
  927. A numeric capability has a value which is a nonnegative number.  Write
  928. the capability name, a `#', and the number, between two colons.  For
  929. example, `...:li#48:...' is how you specify the `li' capability for 48
  930. lines.
  931.  
  932. A string-valued capability has a value which is a sequence of
  933. characters.  Usually these are the characters used to perform some
  934. display operation.  Write the capability name, a `=', and the characters
  935. of the value, between two colons.  For example, `...:cm=\E[%i%d;%dH:...'
  936. is how the cursor motion command for a standard ANSI terminal would be
  937. specified.
  938.  
  939. Special characters in the string value can be expressed using `\'-escape
  940. sequences as in C; in addition, `\E' stands for ESC.  `^' is also a kind
  941. of escape character; `^' followed by CHAR stands for the
  942. control-equivalent of CHAR.  Thus, `^a' stands for the character
  943. control-a, just like `\001'.  `\' and `^' themselves can be represented
  944. as `\\' and `\^'.
  945.  
  946. To include a colon in the string, you must write `\072'.  You might
  947. ask, "Why can't `\:' be used to represent a colon?"  The reason is
  948. that the interrogation functions do not count slashes while looking for a
  949. capability.  Even if `:ce=ab\:cd:' were interpreted as giving the
  950. `ce' capability the value `ab:cd', it would also appear to define
  951. `cd' as a flag.
  952.  
  953. The string value will often contain digits at the front to specify padding
  954. (*Note Padding::) and/or `%'-sequences within to specify how to encode
  955. parameters (*Note Parameters::).  Although these things are not to be
  956. output literally to the terminal, they are considered part of the value of
  957. the capability.  They are special only when the string value is processed
  958. by `tputs', `tparam' or `tgoto'.  By contrast, `\' and
  959. `^' are considered part of the syntax for specifying the characters
  960. in the string.
  961.  
  962. Let's look at the VT52 example again:
  963.  
  964.      dw|vt52|DEC vt52:\
  965.              :cr=^M:do=^J:nl=^J:bl=^G:\
  966.              :le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:cm=\EY%+ %+ :co#80:li#24:\
  967.              :nd=\EC:ta=^I:pt:sr=\EI:up=\EA:\
  968.              :ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H:
  969.  
  970. Here we see the numeric-valued capabilities `co' and `li', the
  971. flags `bs' and `pt', and many string-valued capabilities.  Most
  972. of the strings start with ESC represented as `\E'.  The rest
  973. contain control characters represented using `^'.  The meanings of the
  974. individual capabilities are defined elsewhere (*Note Capabilities::).
  975.  
  976.  
  977. File: termcap  Node: Naming, Prev: Capability Format, Up: Data Base, Next: Inheriting
  978.  
  979. Terminal Type Name Conventions
  980. ==============================
  981.  
  982. There are conventions for choosing names of terminal types.  For one thing,
  983. all letters should be in lower case.  The terminal type for a terminal in
  984. its most usual or most fundamental mode of operation should not have a
  985. hyphen in it.
  986.  
  987. If the same terminal has other modes of operation which require
  988. different terminal descriptions, these variant descriptions are given
  989. names made by adding suffixes with hyphens.  Such alternate descriptions
  990. are used for two reasons:
  991.  
  992.    * When the terminal has a switch that changes its behavior.  Since the
  993.      computer cannot tell how the switch is set, the user must tell the
  994.      computer by choosing the appropriate terminal type name.
  995.  
  996.      For example, the VT-100 has a setup flag that controls whether the
  997.      cursor wraps at the right margin.  If this flag is set to "wrap",
  998.      you must use the terminal type `vt100-am'.  Otherwise you must use
  999.      `vt100-nam'.  Plain `vt100' is defined as a synonym for either
  1000.      `vt100-am' or `vt100-nam' depending on the preferences of the local
  1001.      site.
  1002.  
  1003.      The standard suffix `-am' stands for "automatic margins".
  1004.  
  1005.    * To give the user a choice in how to use the terminal.  This is done
  1006.      when the terminal has a switch that the computer normally controls.
  1007.  
  1008.      For example, the Ann Arbor Ambassador can be configured with many
  1009.      screen sizes ranging from 20 to 60 lines.  Fewer lines make bigger
  1010.      characters but more lines let you see more of what you are editing.
  1011.      As a result, users have different preferences.  Therefore, termcap
  1012.      provides terminal types for many screen sizes.  If you choose type
  1013.      `aaa-30', the terminal will be configured to use 30 lines; if you
  1014.      choose `aaa-48', 48 lines will be used, and so on.
  1015.  
  1016. Here is a list of standard suffixes and their conventional meanings:
  1017.  
  1018. `-w'
  1019.      Short for "wide".  This is a mode that gives the terminal more
  1020.      columns than usual.  This is normally a user option.
  1021.  
  1022. `-am'
  1023.      "Automatic margins".  This is an alternate description for use when
  1024.      the terminal's margin-wrap switch is on; it contains the `am'
  1025.      flag.  The implication is that normally the switch is off and the
  1026.      usual description for the terminal says that the switch is off.
  1027.  
  1028. `-nam'
  1029.      "No automatic margins".  The opposite of `-am', this names an
  1030.      alternative description which lacks the `am' flag.  This implies
  1031.      that the terminal is normally operated with the margin-wrap switch
  1032.      turned on, and the normal description of the terminal says so.
  1033.  
  1034. `-na'
  1035.      "No arrows".  This terminal description initializes the terminal to
  1036.      keep its arrow keys in local mode.  This is a user option.
  1037.  
  1038. `-rv'
  1039.      "Reverse video".  This terminal description causes text output for
  1040.      normal video to appear as reverse, and text output for reverse
  1041.      video to come out as normal.  Often this description differs from
  1042.      the usual one by interchanging the two strings which turn reverse
  1043.      video on and off.
  1044.  
  1045.      This is a user option; you can choose either the "reverse video"
  1046.      variant terminal type or the normal terminal type, and termcap will
  1047.      obey.
  1048.  
  1049. `-s'
  1050.      "Status".  Says to enable use of a status line which ordinary output
  1051.      does not touch (*Note Status Line::).
  1052.  
  1053.      Some terminals have a special line that is used only as a status line.
  1054.      For these terminals, there is no need for an `-s' variant; the
  1055.      status line commands should be defined by default.  On other
  1056.      terminals, enabling a status line means removing one screen line from
  1057.      ordinary use and reducing the effective screen height.  For these
  1058.      terminals, the user can choose the `-s' variant type to request
  1059.      use of a status line.
  1060.  
  1061. `-NLINES'
  1062.      Says to operate with NLINES lines on the screen, for terminals
  1063.      such as the Ambassador which provide this as an option.  Normally this
  1064.      is a user option; by choosing the terminal type, you control how many
  1065.      lines termcap will use.
  1066.  
  1067. `-NPAGESp'
  1068.      Says that the terminal has NPAGES pages worth of screen memory,
  1069.      for terminals where this is a hardware option.
  1070.  
  1071. `-unk'
  1072.      Says that description is not for direct use, but only for reference in
  1073.      `tc' capabilities.  Such a description is a kind of subroutine,
  1074.      because it describes the common characteristics of several variant
  1075.      descriptions that would use other suffixes in place of `-unk'.
  1076.  
  1077.  
  1078. File: termcap  Node: Inheriting, Prev: Naming, Up: Data Base
  1079.  
  1080. Inheriting from Related Descriptions
  1081. ====================================
  1082.  
  1083. When two terminal descriptions are similar, their identical parts do not
  1084. need to be given twice.  Instead, one of the two can be defined in terms of
  1085. the other, using the `tc' capability.  We say that one description
  1086. "refers to" the other, or "inherits from" the other.
  1087.  
  1088. The `tc' capability must be the last one in the terminal description,
  1089. and its value is a string which is the name of another terminal type which
  1090. is referred to.  For example,
  1091.  
  1092.      N9|aaa|ambassador|aaa-30|ann arbor ambassador/30 lines:\
  1093.              :ti=\E[2J\E[30;0;0;30p:\
  1094.              :te=\E[60;0;0;30p\E[30;1H\E[J:\
  1095.              :li#30:tc=aaa-unk:
  1096.  
  1097. defines the terminal type `aaa-30' (also known as plain `aaa') in
  1098. terms of `aaa-unk', which defines everything about the Ambassador that
  1099. is independent of screen height.  The types `aaa-36', `aaa-48'
  1100. and so on for other screen heights are likewise defined to inherit from
  1101. `aaa-unk'.
  1102.  
  1103. The capabilities overridden by `aaa-30' include `li', which says
  1104. how many lines there are, and `ti' and `te', which configure the
  1105. terminal to use that many lines.
  1106.  
  1107. The effective terminal description for type `aaa' consists of the text
  1108. shown above followed by the text of the description of `aaa-unk'.  The
  1109. `tc' capability is handled automatically by `tgetent', which
  1110. finds the description thus referenced and combines the two descriptions
  1111. (*Note Find::).  Therefore, only the implementor of the terminal
  1112. descriptions needs to think about using `tc'.  Users and application
  1113. programmers do not need to be concerned with it.
  1114.  
  1115. Since the reference terminal description is used last, capabilities
  1116. specified in the referring description override any specifications of the
  1117. same capabilities in the reference description.
  1118.  
  1119. The referring description can cancel out a capability without specifying
  1120. any new value for it by means of a special trick.  Write the capability in
  1121. the referring description, with the character `@' after the capability
  1122. name, as follows:
  1123.  
  1124.      NZ|aaa-30-nam|ann arbor ambassador/30 lines/no automatic-margins:\
  1125.              :am@:tc=aaa-30:
  1126.  
  1127.  
  1128. File: termcap  Node: Capabilities, Prev: Data Base, Up: Top, Next: Summary
  1129.  
  1130. Definitions of the Terminal Capabilities
  1131. ****************************************
  1132.  
  1133. This section is divided into many subsections, each for one aspect of
  1134. use of display terminals.  For writing a display program, you usually need
  1135. only check the subsections for the operations you want to use.  For writing
  1136. a terminal description, you must read each subsection and fill in the
  1137. capabilities described there.
  1138.  
  1139. String capabilities that are display commands may require numeric
  1140. parameters (*Note Parameters::).  Most such capabilities do not use
  1141. parameters.  When a capability requires parameters, this is explicitly
  1142. stated at the beginning of its definition.  In simple cases, the first or
  1143. second sentence of the definition mentions all the parameters, in the order
  1144. they should be given, using a name
  1145. in upper case
  1146. for each one.  For example, the `rp' capability is a command that
  1147. requires two parameters; its definition begins as follows:
  1148.  
  1149.      String of commands to output a graphic character C, repeated N
  1150.      times.
  1151.  
  1152. In complex cases or when there are many parameters, they are described
  1153. explicitly.
  1154.  
  1155. When a capability is described as obsolete, this means that programs should
  1156. not be written to look for it, but terminal descriptions should still be
  1157. written to provide it.
  1158.  
  1159. When a capability is described as very obsolete, this means that it should
  1160. be omitted from terminal descriptions as well.
  1161.  
  1162. * Menu:
  1163.  
  1164. * Basic::             Basic characteristics.
  1165. * Screen Size::       Screen size, and what happens when it changes.
  1166. * Cursor Motion::     Various ways to move the cursor.
  1167. * Scrolling::         Pushing text up and down on the screen.
  1168. * Wrapping::          What happens if you write a character in the last column.
  1169. * Windows::           Limiting the part of the window that output affects.
  1170. * Clearing::          Erasing one or many lines.
  1171. * Insdel Line::       Making new blank lines in mid-screen; deleting lines.
  1172. * Insdel Char::       Inserting and deleting characters within a line.
  1173. * Standout::          Highlighting some of the text.
  1174. * Underlining::       Underlining some of the text.
  1175. * Cursor Visibility:: Making the cursor more or less easy to spot.
  1176. * Bell::              Attracts user's attention; not localized on the screen.
  1177. * Keypad::            Recognizing when function keys or arrows are typed.
  1178. * Meta Key::          META acts like an extra shift key.
  1179. * Initialization::    Commands used to initialize or reset the terminal.
  1180. * Pad Specs::         Info for the kernel on how much padding is needed.
  1181. * Status Line::       A status line displays "background" information.
  1182. * Half-Line::         Moving by half-lines, for superscripts and subscripts.
  1183. * Printer::           Controlling auxiliary printers of display terminals.
  1184.  
  1185.  
  1186. File: termcap  Node: Basic, Prev: Capabilities, Up: Capabilities, Next: Screen Size
  1187.  
  1188. Basic Characteristics
  1189. =====================
  1190.  
  1191. This section documents the capabilities that describe the basic and
  1192. nature of the terminal, and also those that are relevant to the output
  1193. of graphic characters.
  1194.  
  1195. `os'
  1196.      Flag whose presence means that the terminal can overstrike.  This
  1197.      means that outputting a graphic character does not erase whatever was
  1198.      present in the same character position before.  The terminals that can
  1199.      overstrike include printing terminals, storage tubes (all obsolete
  1200.      nowadays), and many bit-map displays.
  1201.  
  1202. `eo'
  1203.      Flag whose presence means that outputting a space can erase an
  1204.      overstrike.  If this is not present and overstriking is supported,
  1205.      output of a space has no effect except to move the cursor.
  1206.  
  1207. `gn'
  1208.      Flag whose presence means that this terminal type is a generic type
  1209.      which does not really describe any particular terminal.  Generic types
  1210.      are intended for use as the default type assigned when the user
  1211.      connects to the system, with the intention that the user should
  1212.      specify what type he really has.  One example of a generic type
  1213.      is the type `network'.
  1214.  
  1215.      Since the generic type cannot say how to do anything interesting with
  1216.      the terminal, termcap-using programs will always find that the
  1217.      terminal is too weak to be supported if the user has failed to specify
  1218.      a real terminal type in place of the generic one.  The `gn' flag
  1219.      directs these programs to use a different error message: "You have
  1220.      not specified your real terminal type", rather than "Your terminal
  1221.      is not powerful enough to be used".
  1222.  
  1223. `hc'
  1224.      Flag whose presence means this is a hardcopy terminal.
  1225.  
  1226. `rp'
  1227.      String of commands to output a graphic character C, repeated N
  1228.      times.  The first parameter value is the ASCII code for the desired
  1229.      character, and the second parameter is the number of times to repeat the
  1230.      character.  Often this command requires padding proportional to the 
  1231.      number of times the character is repeated.  This effect can be had by
  1232.      using parameter arithmetic with `%'-sequences to compute the
  1233.      amount of padding, then generating the result as a number at the front
  1234.      of the string so that `tputs' will treat it as padding.
  1235.  
  1236. `hz'
  1237.      Flag whose presence means that the ASCII character `~' cannot be
  1238.      output on this terminal because it is used for display commands.
  1239.  
  1240.      Programs handle this flag by checking all text to be output and
  1241.      replacing each `~' with some other character(s).  If this is not
  1242.      done, the screen will be thoroughly garbled.
  1243.  
  1244.      The old Hazeltine terminals that required such treatment are probably
  1245.      very rare today, so you might as well not bother to support this flag.
  1246.  
  1247. `CC'
  1248.      String whose presence means the terminal has a settable command
  1249.      character.  The value of the string is the default command character
  1250.      (which is usually ESC).
  1251.  
  1252.      All the strings of commands in the terminal description should be
  1253.      written to use the default command character.  If you are writing an
  1254.      application program that changes the command character, use the
  1255.      `CC' capability to figure out how to translate all the display
  1256.      commands to work with the new command character.
  1257.  
  1258.      Most programs have no reason to look at the `CC' capability.
  1259.  
  1260. `xb'
  1261.      Flag whose presence identifies Superbee terminals which are unable to
  1262.      transmit the characters ESC and `Control-C'.  Programs which
  1263.      support this flag are supposed to check the input for the code sequences
  1264.      sent by the F1 and F2 keys, and pretend that ESC
  1265.      or `Control-C' (respectively) had been read.  But this flag is
  1266.      obsolete, and not worth supporting.
  1267.  
  1268.  
  1269. File: termcap  Node: Screen Size, Prev: Basic, Up: Capabilities, Next: Cursor Motion
  1270.  
  1271. Screen Size
  1272. ===========
  1273.  
  1274. A terminal description has two capabilities, `co' and `li',
  1275. that describe the screen size in columns and lines.  But there is more
  1276. to the question of screen size than this.
  1277.  
  1278. On some operating systems the "screen" is really a window and the
  1279. effective width can vary.  On some of these systems, `tgetnum'
  1280. uses the actual width of the window to decide what value to return for
  1281. the `co' capability, overriding what is actually written in the
  1282. terminal description.  On other systems, it is up to the application
  1283. program to check the actual window width using a system call.  For
  1284. example, on BSD 4.3 systems, the system call `ioctl' with code
  1285. `TIOCGWINSZ' will tell you the current screen size.
  1286.  
  1287. On all window systems, termcap is powerless to advise the application
  1288. program if the user resizes the window.  Application programs must
  1289. deal with this possibility in a system-dependent fashion.  On some
  1290. systems the C shell handles part of the problem by detecting changes
  1291. in window size and setting the `TERMCAP' environment variable
  1292. appropriately.  This takes care of application programs that are
  1293. started subsequently.  It does not help application programs already
  1294. running.
  1295.  
  1296. On some systems, including BSD 4.3, all programs using a terminal get
  1297. a signal named `SIGWINCH' whenever the screen size changes.
  1298. Programs that use termcap should handle this signal by using
  1299. `ioctl TIOCGWINSZ' to learn the new screen size.
  1300.  
  1301. `co'
  1302.      Numeric value, the width of the screen in character positions.  Even
  1303.      hardcopy terminals normally have a `co' capability.
  1304.  
  1305. `li'
  1306.      Numeric value, the height of the screen in lines.
  1307.  
  1308.  
  1309. File: termcap  Node: Cursor Motion, Prev: Screen Size, Up: Capabilities, Next: Wrapping
  1310.  
  1311. Cursor Motion
  1312. =============
  1313.  
  1314. Termcap assumes that the terminal has a "cursor", a spot on the screen
  1315. where a visible mark is displayed, and that most display commands take
  1316. effect at the position of the cursor.  It follows that moving the cursor
  1317. to a specified location is very important.
  1318.  
  1319. There are many terminal capabilities for different cursor motion
  1320. operations.  A terminal description should define as many as possible, but
  1321. most programs do not need to use most of them.  One capability, `cm',
  1322. moves the cursor to an arbitrary place on the screen; this by itself is
  1323. sufficient for any application as long as there is no need to support
  1324. hardcopy terminals or certain old, weak displays that have only relative
  1325. motion commands.  Use of other cursor motion capabilities is an
  1326. optimization, enabling the program to output fewer characters in some
  1327. common cases.
  1328.  
  1329. If you plan to use the relative cursor motion commands in an application
  1330. program, you must know what the starting cursor position is.  To do this,
  1331. you must keep track of the cursor position and update the records each
  1332. time anything is output to the terminal, including graphic characters.
  1333. In addition, it is necessary to know whether the terminal wraps after
  1334. writing in the rightmost column.  *Note Wrapping::.
  1335.  
  1336. One other motion capability needs special mention: `nw' moves the
  1337. cursor to the beginning of the following line, perhaps clearing all the
  1338. starting line after the cursor, or perhaps not clearing at all.  This
  1339. capability is a least common denominator that is probably supported even by
  1340. terminals that cannot do most other things such as `cm' or `do'.
  1341. Even hardcopy terminals can support `nw'.
  1342.  
  1343. `cm'
  1344.      String of commands to position the cursor at line L, column C.
  1345.      Both parameters are origin-zero, and are defined relative to the
  1346.      screen, not relative to display memory.
  1347.  
  1348.      All display terminals except a few very obsolete ones support `cm',
  1349.      so it is acceptable for an application program to refuse to operate on
  1350.      terminals lacking `cm'.
  1351.  
  1352. `ho'
  1353.      String of commands to move the cursor to the upper left corner of the
  1354.      screen (this position is called the "home position").  In
  1355.      terminals where the upper left corner of the screen is not the same as
  1356.      the beginning of display memory, this command must go to the upper
  1357.      left corner of the screen, not the beginning of display memory.
  1358.  
  1359.      Every display terminal supports this capability, and many application
  1360.      programs refuse to operate if the `ho' capability is missing.
  1361.  
  1362. `ll'
  1363.      String of commands to move the cursor to the lower left corner of the
  1364.      screen.  On some terminals, moving up from home position does this,
  1365.      but programs should never assume that will work.  Just output the
  1366.      `ll' string (if it is provided); if moving to home position and
  1367.      then moving up is the best way to get there, the `ll' command
  1368.      will do that.
  1369.  
  1370. `cr'
  1371.      String of commands to move the cursor to the beginning of the line it
  1372.      is on.  If this capability is not specified, many programs assume
  1373.      they can use the ASCII carriage return character for this.
  1374.  
  1375. `le'
  1376.      String of commands to move the cursor left one column.  Unless the
  1377.      `bw' flag capability is specified, the effect is undefined if the
  1378.      cursor is at the left margin; do not use this command there.  If
  1379.      `bw' is present, this command may be used at the left margin, and
  1380.      it wraps the cursor to the last column of the preceding line.
  1381.  
  1382. `nd'
  1383.      String of commands to move the cursor right one column.  The effect is
  1384.      undefined if the cursor is at the right margin; do not use this
  1385.      command there, not even if `am' is present.
  1386.  
  1387. `up'
  1388.      String of commands to move the cursor vertically up one line.  The
  1389.      effect of sending this string when on the top line is undefined;
  1390.      programs should never use it that way.
  1391.  
  1392. `do'
  1393.      String of commands to move the cursor vertically down one line.  The
  1394.      effect of sending this string when on the bottom line is undefined;
  1395.      programs should never use it that way.
  1396.  
  1397.      The original idea was that this string would not contain a newline
  1398.      character and therefore could be used without disabling the kernel's usual
  1399.      habit of converting of newline into a carriage-return newline sequence.
  1400.      But many terminal descriptions do use newline in the `do' string, so
  1401.      this is not possible; a program which sends the `do' string must
  1402.      disable output conversion in the kernel (*Note Initialize::).
  1403.  
  1404. `bw'
  1405.      Flag whose presence says that `le' may be used in column zero
  1406.      to move to the last column of the preceding line.  If this flag
  1407.      is not present, `le' should not be used in column zero.
  1408.  
  1409. `nw'
  1410.      String of commands to move the cursor to start of next line, possibly
  1411.      clearing rest of line (following the cursor) before moving.
  1412.  
  1413. `DO', `UP', `LE', `RI'
  1414.      Strings of commands to move the cursor N lines down vertically,
  1415.      up vertically, or N columns left or right.  Do not attempt to
  1416.      move past any edge of the screen with these commands; the effect of
  1417.      trying that is undefined.  Only a few terminal descriptions provide
  1418.      these commands, and most programs do not use them.
  1419.  
  1420. `CM'
  1421.      String of commands to position the cursor at line L, column
  1422.      C, relative to display memory.  Both parameters are origin-zero.
  1423.      This capability is present only in terminals where there is a
  1424.      difference between screen-relative and memory-relative addressing, and
  1425.      not even in all such terminals.
  1426.  
  1427. `ch'
  1428.      String of commands to position the cursor at column C in the
  1429.      same line it is on.  This is a special case of `cm' in which the
  1430.      vertical position is not changed.  The `ch' capability is
  1431.      provided only when it is faster to output than `cm' would be in
  1432.      this special case.  Programs should not assume most display terminals
  1433.      have `ch'.
  1434.  
  1435. `cv'
  1436.      String of commands to position the cursor at line L in the same
  1437.      column.  This is a special case of `cm' in which the horizontal
  1438.      position is not changed.  The `cv' capability is provided only
  1439.      when it is faster to output than `cm' would be in this special
  1440.      case.  Programs should not assume most display terminals have
  1441.      `cv'.
  1442.  
  1443. `sc'
  1444.      String of commands to make the terminal save the current cursor
  1445.      position.  Only the last saved position can be used.  If this
  1446.      capability is present, `rc' should be provided also.  Most
  1447.      terminals have neither.
  1448.  
  1449. `rc'
  1450.      String of commands to make the terminal restore the last saved cursor
  1451.      position.  If this capability is present, `sc' should be provided
  1452.      also.  Most terminals have neither.
  1453.  
  1454. `ff'
  1455.      String of commands to advance to the next page, for a hardcopy
  1456.      terminal.
  1457.  
  1458. `ta'
  1459.      String of commands to move the cursor right to the next hardware tab
  1460.      stop column.  Missing if the terminal does not have any kind of
  1461.      hardware tabs.  Do not send this command if the kernel's terminal
  1462.      modes say that the kernel is expanding tabs into spaces.
  1463.  
  1464. `bt'
  1465.      String of commands to move the cursor left to the previous hardware
  1466.      tab stop column.  Missing if the terminal has no such ability; many
  1467.      terminals do not.  Do not send this command if the kernel's terminal
  1468.      modes say that the kernel is expanding tabs into spaces.
  1469.  
  1470. The following obsolete capabilities should be included in terminal
  1471. descriptions when appropriate, but should not be looked at by new programs.
  1472.  
  1473. `nc'
  1474.      Flag whose presence means the terminal does not support the ASCII
  1475.      carriage return character as `cr'.  This flag is needed because
  1476.      old programs assume, when the `cr' capability is missing, that
  1477.      ASCII carriage return can be used for the purpose.  We use `nc'
  1478.      to tell the old programs that carriage return may not be used.
  1479.  
  1480.      New programs should not assume any default for `cr', so they need
  1481.      not look at `nc'.  However, descriptions should contain `nc'
  1482.      whenever they do not contain `cr'.
  1483.  
  1484. `xt'
  1485.      Flag whose presence means that the ASCII tab character may not be used
  1486.      for cursor motion.  This flag exists because old programs assume, when
  1487.      the `ta' capability is missing, that ASCII tab can be used for
  1488.      the purpose.  We use `xt' to tell the old programs not to use tab.
  1489.  
  1490.      New programs should not assume any default for `ta', so they need
  1491.      not look at `xt' in connection with cursor motion.  Note that
  1492.      `xt' also has implications for standout mode (*Note Standout::).
  1493.      It is obsolete in regard to cursor motion but not in regard to
  1494.      standout.
  1495.  
  1496.      In fact, `xt' means that the terminal is a Teleray 1061.
  1497.  
  1498. `bc'
  1499.      Very obsolete alternative name for the `le' capability.
  1500.  
  1501. `bs'
  1502.      Flag whose presence means that the ASCII character backspace may be
  1503.      used to move the cursor left.  Obsolete; look at `le' instead.
  1504.  
  1505. `nl'
  1506.      Obsolete capability which is a string that can either be used to move
  1507.      the cursor down or to scroll.  The same string must scroll when used
  1508.      on the bottom line and move the cursor when used on any other line.
  1509.      New programs should use `do' or `sf', and ignore `nl'.
  1510.  
  1511.      If there is no `nl' capability, some old programs assume they can
  1512.      use the newline character for this purpose.  These programs follow a
  1513.      bad practice, but because they exist, it is still desirable to define
  1514.      the `nl' capability in a terminal description if the best way to
  1515.      move down is *not* a newline.
  1516.  
  1517.  
  1518. File: termcap  Node: Wrapping, Prev: Cursor Motion, Up: Capabilities, Next: Scrolling
  1519.  
  1520. Wrapping
  1521. ========
  1522.  
  1523. "Wrapping" means moving the cursor from the right margin to the left
  1524. margin of the following line.  Some terminals wrap automatically when a
  1525. graphic character is output in the last column, while others do not.  Most
  1526. application programs that use termcap need to know whether the terminal
  1527. wraps.  There are two special flag capabilities to describe what the
  1528. terminal does when a graphic character is output in the last column.
  1529.  
  1530. `am'
  1531.      Flag whose presence means that writing a character in the last column
  1532.      causes the cursor to wrap to the beginning of the next line.
  1533.  
  1534.      If `am' is not present, writing in the last column leaves the
  1535.      cursor at the place where the character was written.
  1536.  
  1537.      Writing in the last column of the last line should be avoided on
  1538.      terminals with `am', as it may or may not cause scrolling to
  1539.      occur (*Note Scrolling::).  Scrolling is surely not what you would
  1540.      intend.
  1541.  
  1542.      If your program needs to check the `am' flag, then it also needs
  1543.      to check the `xn' flag which indicates that wrapping happens in a
  1544.      strange way.  Many common terminals have the `xn' flag.
  1545.  
  1546. `xn'
  1547.      Flag whose presence means that the cursor wraps in a strange way.  At
  1548.      least two distinct kinds of strange behavior are known; the termcap
  1549.      data base does not contain anything to distinguish the two.
  1550.  
  1551.      On Concept-100 terminals, output in the last column wraps the cursor
  1552.      almost like an ordinary `am' terminal.  But if the next thing
  1553.      output is a newline, it is ignored.
  1554.  
  1555.      DEC VT-100 terminals (when the wrap switch is on) do a different
  1556.      strange thing: the cursor wraps only if the next thing output is
  1557.      another graphic character.  In fact, the wrap occurs when the
  1558.      following graphic character is received by the terminal, before the
  1559.      character is placed on the screen.
  1560.  
  1561.      On both of these terminals, after writing in the last column a
  1562.      following graphic character will be displayed in the first column of
  1563.      the following line.  But the effect of relative cursor motion
  1564.      characters such as newline or backspace at such a time depends on the
  1565.      terminal.  The effect of erase or scrolling commands also depends on
  1566.      the terminal.  You can't assume anything about what they will do on a
  1567.      terminal that has `xn'.  So, to be safe, you should never do
  1568.      these things at such a time on such a terminal.
  1569.  
  1570.      To be sure of reliable results on a terminal which has the `xn'
  1571.      flag, output a `cm' absolute positioning command after writing in
  1572.      the last column.  Another safe thing to do is to output carriage-return
  1573.      newline, which will leave the cursor at the beginning of the following
  1574.      line.
  1575.  
  1576.  
  1577. File: termcap  Node: Scrolling, Prev: Wrapping, Up: Capabilities, Next: Windows
  1578.  
  1579. Scrolling
  1580. =========
  1581.  
  1582. "Scrolling" means moving the contents of the screen up or down one or
  1583. more lines.  Moving the contents up is "forward scrolling"; moving them
  1584. down is "reverse scrolling".
  1585.  
  1586. Scrolling happens after each line of output during ordinary output on most
  1587. display terminals.  But in an application program that uses termcap for
  1588. random-access output, scrolling happens only when explicitly requested with
  1589. the commands in this section.
  1590.  
  1591. Some terminals have a "scroll region" feature.  This lets you limit
  1592. the effect of scrolling to a specified range of lines.  Lines outside the
  1593. range are unaffected when scrolling happens.  The scroll region feature
  1594. is available if either `cs' or `cS' is present.
  1595.  
  1596. `sf'
  1597.      String of commands to scroll the screen one line up, assuming it is
  1598.      output with the cursor at the beginning of the bottom line.
  1599.  
  1600. `sr'
  1601.      String of commands to scroll the screen one line down, assuming it is
  1602.      output with the cursor at the beginning of the top line.
  1603.  
  1604. `SF'
  1605.      String of commands to scroll the screen N lines up, assuming it
  1606.      is output with the cursor at the beginning of the bottom line.
  1607.  
  1608. `SR'
  1609.      String of commands to scroll the screen N line down, assuming it
  1610.      is output with the cursor at the beginning of the top line.
  1611.  
  1612. `cs'
  1613.      String of commands to set the scroll region.  This command takes two
  1614.      parameters, START and END, which are the line numbers
  1615.      (origin-zero) of the first line to include in the scroll region and of
  1616.      the last line to include in it.  When a scroll region is set,
  1617.      scrolling is limited to the specified range of lines; lines outside
  1618.      the range are not affected by scroll commands.
  1619.  
  1620.      Do not try to move the cursor outside the scroll region.  The region
  1621.      remains set until explicitly removed.  To remove the scroll region,
  1622.      use another `cs' command specifying the full height of the
  1623.      screen.
  1624.  
  1625.      The cursor position is undefined after the `cs' command is set,
  1626.      so position the cursor with `cm' immediately afterward.
  1627.  
  1628. `cS'
  1629.      String of commands to set the scroll region using parameters in
  1630.      different form.  The effect is the same as if `cs' were used.
  1631.      Four parameters are required:
  1632.  
  1633.        1. Total number of lines on the screen.
  1634.        2. Number of lines above desired scroll region.
  1635.        3. Number of lines below (outside of) desired scroll region.
  1636.        4. Total number of lines on the screen, the same as the first parameter.
  1637.  
  1638.      This capability is a GNU extension that was invented to allow the Ann
  1639.      Arbor Ambassador's scroll-region command to be described; it could
  1640.      also be done by putting non-Unix `%'-sequences into a `cs'
  1641.      string, but that would have confused Unix programs that used the
  1642.      `cs' capability with the Unix termcap.  Currently only GNU Emacs
  1643.      uses the `cS' capability.
  1644.  
  1645. `ns'
  1646.      Flag which means that the terminal does not normally scroll for
  1647.      ordinary sequential output.  For modern terminals, this means that
  1648.      outputting a newline in ordinary sequential output with the cursor on
  1649.      the bottom line wraps to the top line.  For some obsolete terminals,
  1650.      other things may happen.
  1651.  
  1652.      The terminal may be able to scroll even if it does not normally do so.
  1653.      If the `sf' capability is provided, it can be used for scrolling
  1654.      regardless of `ns'.
  1655.  
  1656. `da'
  1657.      Flag whose presence means that lines scrolled up off the top of the
  1658.      screen may come back if scrolling down is done subsequently.
  1659.  
  1660.      The `da' and `db' flags do not, strictly speaking, affect
  1661.      how to scroll.  But programs that scroll usually need to clear the
  1662.      lines scrolled onto the screen, if these flags are present.
  1663.  
  1664. `db'
  1665.      Flag whose presence means that lines scrolled down off the bottom of
  1666.      the screen may come back if scrolling up is done subsequently.
  1667.  
  1668. `lm'
  1669.      Numeric value, the number of lines of display memory that the terminal
  1670.      has.  A value of zero means that the terminal has more display memory
  1671.      than can fit on the screen, but no fixed number of lines.  (The number
  1672.      of lines may depend on the amount of text in each line.)
  1673.  
  1674. Any terminal description that defines `SF' should also define `sf';
  1675. likewise for `SR' and `sr'.  However, many terminals can only scroll by
  1676. one line at a time, so it is common to find `sf' and not `SF', or `sr'
  1677. without `SR'.
  1678.  
  1679. Therefore, all programs that use the scrolling facilities should be
  1680. prepared to work with `sf' in the case that `SF' is absent, and likewise
  1681. with `sr'.  On the other hand, an application program that uses only
  1682. `sf' and not `SF' is acceptable, though slow on some terminals.
  1683.  
  1684. When outputting a scroll command with `tputs', the NLINES
  1685. argument should be the total number of lines in the portion of the screen
  1686. being scrolled.  Very often these commands require padding proportional to
  1687. this number of lines.  *Note Padding::.
  1688.  
  1689.  
  1690. File: termcap  Node: Windows, Prev: Scrolling, Up: Capabilities, Next: Clearing
  1691.  
  1692. Windows
  1693. =======
  1694.  
  1695. A "window", in termcap, is a rectangular portion of the screen to which
  1696. all display operations are restricted.  Wrapping, clearing, scrolling,
  1697. insertion and deletion all operate as if the specified window were all the
  1698. screen there was.
  1699.  
  1700. `wi'
  1701.      String of commands to set the terminal output screen window.
  1702.      This string requires four parameters, all origin-zero:
  1703.        1. The first line to include in the window.
  1704.        2. The last line to include in the window.
  1705.        3. The first column to include in the window.
  1706.        4. The last column to include in the window.
  1707.  
  1708. Most terminals do not support windows.
  1709.  
  1710.  
  1711. File: termcap  Node: Clearing, Prev: Windows, Up: Capabilities, Next: Insdel Line
  1712.  
  1713. Clearing Parts of the Screen
  1714. ============================
  1715.  
  1716. There are several terminal capabilities for clearing parts of the screen
  1717. to blank.  All display terminals support the `cl' string, and most
  1718. display terminals support all of these capabilities.
  1719.  
  1720. `cl'
  1721.      String of commands to clear the entire screen and position the cursor
  1722.      at the upper left corner.
  1723.  
  1724. `cd'
  1725.      String of commands to clear the line the cursor is on, and all the
  1726.      lines below it, down to the bottom of the screen.  This command string
  1727.      should be used only with the cursor in column zero; their effect is
  1728.      undefined if the cursor is elsewhere.
  1729.  
  1730. `ce'
  1731.      String of commands to clear from the cursor to the end of the current
  1732.      line.
  1733.  
  1734. `ec'
  1735.      String of commands to clear N characters, starting with the
  1736.      character that the cursor is on.  This command string is expected to
  1737.      leave the cursor position unchanged.  The parameter N should never
  1738.      be large enough to reach past the right margin; the effect of such a
  1739.      large parameter would be undefined.
  1740.  
  1741. Clear to end of line (`ce') is extremely important in programs that
  1742. maintain an updating display.  Nearly all display terminals support this
  1743. operation, so it is acceptable for a an application program to refuse to
  1744. work if `ce' is not present.  However, if you do not want this
  1745. limitation, you can accomplish clearing to end of line by outputting spaces
  1746. until you reach the right margin.  In order to do this, you must know the
  1747. current horizontal position.  Also, this technique assumes that writing a
  1748. space will erase.  But this happens to be true on all the display terminals
  1749. that fail to support `ce'.
  1750.  
  1751.  
  1752. File: termcap  Node: Insdel Line, Prev: Clearing, Up: Capabilities, Next: Insdel Char
  1753.  
  1754. Insert/Delete Line
  1755. ==================
  1756.  
  1757. "Inserting a line" means creating a blank line in the middle
  1758. of the screen, and pushing the existing lines of text apart.  In fact,
  1759. the lines above the insertion point do not change, while the lines below
  1760. move down, and one is normally lost at the bottom of the screen.
  1761.  
  1762. "Deleting a line" means causing the line to disappear from the screen,
  1763. closing up the gap by moving the lines below it upward.  A new line
  1764. appears at the bottom of the screen.  Usually this line is blank, but
  1765. on terminals with the `db' flag it may be a line previously moved
  1766. off the screen bottom by scrolling or line insertion.
  1767.  
  1768. Insertion and deletion of lines is useful in programs that maintain an
  1769. updating display some parts of which may get longer or shorter.  They are
  1770. also useful in editors for scrolling parts of the screen, and for
  1771. redisplaying after lines of text are killed or inserted.
  1772.  
  1773. Many terminals provide commands to insert or delete a single line at the
  1774. cursor position.  Some provide the ability to insert or delete several
  1775. lines with one command, using the number of lines to insert or delete as a
  1776. parameter.  Always move the cursor to column zero before using any of
  1777. these commands.
  1778.  
  1779. `al'
  1780.      String of commands to insert a blank line before the line the cursor
  1781.      is on.  The existing line, and all lines below it, are moved down.
  1782.      The last line in the screen (or in the scroll region, if one is set)
  1783.      disappears and in most circumstances is discarded.  It may not be
  1784.      discarded if the `db' is present (*Note Scrolling::).
  1785.  
  1786.      The cursor must be at the left margin before this command is used.
  1787.      This command does not move the cursor.
  1788.  
  1789. `dl'
  1790.      String of commands to delete the line the cursor is on.  The following
  1791.      lines move up, and a blank line appears at the bottom of the screen
  1792.      (or bottom of the scroll region).  If the terminal has the `db'
  1793.      flag, a nonblank line previously pushed off the screen bottom may
  1794.      reappear at the bottom.
  1795.  
  1796.      The cursor must be at the left margin before this command is used.
  1797.      This command does not move the cursor.
  1798.  
  1799. `AL'
  1800.      String of commands to insert N blank lines before the line that
  1801.      the cursor is on.  It is like `al' repeated N times, except
  1802.      that it is as fast as one `al'.
  1803.  
  1804. `DL'
  1805.      String of commands to delete N lines starting with the line that
  1806.      the cursor is on.  It is like `dl' repeated N times, except
  1807.      that it is as fast as one `dl'.
  1808.  
  1809. Any terminal description that defines `AL' should also define `al';
  1810. likewise for `DL' and `dl'.  However, many terminals can only insert or
  1811. delete one line at a time, so it is common to find `al' and not `AL', or
  1812. `dl' without `DL'.
  1813.  
  1814. Therefore, all programs that use the insert and delete facilities should
  1815. be prepared to work with `al' in the case that `AL' is absent, and
  1816. likewise with `dl'.  On the other hand, it is acceptable to write an
  1817. application that uses only `al' and `dl' and does not look for `AL' or
  1818. `DL' at all.
  1819.  
  1820. If a terminal does not support line insertion and deletion directly,
  1821. but does support a scroll region, the effect of insertion and deletion
  1822. can be obtained with scrolling.  However, it is up to the individual
  1823. user program to check for this possibility and use the scrolling
  1824. commands to get the desired result.  It is fairly important to implement
  1825. this alternate strategy, since it is the only way to get the effect of
  1826. line insertion and deletion on the popular VT100 terminal.
  1827.  
  1828. Insertion and deletion of lines is affected by the scroll region on
  1829. terminals that have a settable scroll region.  This is useful when it is
  1830. desirable to move any few consecutive lines up or down by a few lines.
  1831. *Note Scrolling::.
  1832.  
  1833. The line pushed off the bottom of the screen is not lost if the terminal
  1834. has the `db' flag capability; instead, it is pushed into display
  1835. memory that does not appear on the screen.  This is the same thing that
  1836. happens when scrolling pushes a line off the bottom of the screen.
  1837. Either reverse scrolling or deletion of a line can bring the apparently
  1838. lost line back onto the bottom of the screen.  If the terminal has the
  1839. scroll region feature as well as `db', the pushed-out line really
  1840. is lost if a scroll region is in effect.
  1841.  
  1842. When outputting an insert or delete command with `tputs', the
  1843. NLINES argument should be the total number of lines from the cursor
  1844. to the bottom of the screen (or scroll region).  Very often these commands
  1845. require padding proportional to this number of lines.  *Note Padding::.
  1846.  
  1847. For `AL' and `DL' the NLINES argument should *not*
  1848. depend on the number of lines inserted or deleted; only the total number of
  1849. lines affected.  This is because it is just as fast to insert two or
  1850. N lines with `AL' as to insert one line with `al'.
  1851.  
  1852.  
  1853. File: termcap  Node: Insdel Char, Prev: Insdel Line, Up: Capabilities, Next: Standout
  1854.  
  1855. Insert/Delete Character
  1856. =======================
  1857.  
  1858. "Inserting a character" means creating a blank space in the middle of a
  1859. line, and pushing the rest of the line rightward.  The character in the
  1860. rightmost column is lost.
  1861.  
  1862. "Deleting a character" means causing the character to disappear from
  1863. the screen, closing up the gap by moving the rest of the line leftward.  A
  1864. blank space appears in the rightmost column.
  1865.  
  1866. Insertion and deletion of characters is useful in programs that maintain an
  1867. updating display some parts of which may get longer or shorter.  It is also
  1868. useful in editors for redisplaying the results of editing within a line.
  1869.  
  1870. Many terminals provide commands to insert or delete a single character at
  1871. the cursor position.  Some provide the ability to insert or delete several
  1872. characters with one command, using the number of characters to insert or
  1873. delete as a parameter.
  1874.  
  1875. Many terminals provide an insert mode in which outputting a graphic
  1876. character has the added effect of inserting a position for that character.
  1877. A special command string is used to enter insert mode and another is used
  1878. to exit it.  The reason for designing a terminal with an insert mode rather
  1879. than an insert command is that inserting character positions is usually
  1880. followed by writing characters into them.  With insert mode, this is as
  1881. fast as simply writing the characters, except for the fixed overhead of
  1882. entering and leaving insert mode.  However, when the line speed is great
  1883. enough, padding may be required for the graphic characters output in insert
  1884. mode.
  1885.  
  1886. Some terminals require you to enter insert mode and then output a special
  1887. command for each position to be inserted.  Or they may require special
  1888. commands to be output before or after each graphic character to be
  1889. inserted.
  1890.  
  1891. Deletion of characters is usually accomplished by a straightforward command
  1892. to delete one or several positions; but on some terminals, it is necessary
  1893. to enter a special delete mode before using the delete command, and leave
  1894. delete mode afterward.  Sometimes delete mode and insert mode are the same
  1895. mode.
  1896.  
  1897. Some terminals make a distinction between character positions in which a
  1898. space character has been output and positions which have been cleared.  On
  1899. these terminals, the effect of insert or delete character runs to the first
  1900. cleared position rather than to the end of the line.  In fact, the effect
  1901. may run to more than one line if there is no cleared position to stop the
  1902. shift on the first line.  These terminals are identified by the `in'
  1903. flag capability.
  1904.  
  1905. On terminals with the `in' flag, the technique of skipping over
  1906. characters that you know were cleared, and then outputting text later on in
  1907. the same line, causes later insert and delete character operations on that
  1908. line to do nonstandard things.  A program that has any chance of doing this
  1909. must check for the `in' flag and must be careful to write explicit
  1910. space characters into the intermediate columns when `in' is present.
  1911.  
  1912. A plethora of terminal capabilities are needed to describe all of this
  1913. complexity.  Here is a list of them all.  Following the list, we present
  1914. an algorithm for programs to use to take proper account of all of these
  1915. capabilities.
  1916.  
  1917. `im'
  1918.      String of commands to enter insert mode.
  1919.  
  1920.      If the terminal has no special insert mode, but it can insert
  1921.      characters with a special command, `im' should be defined with a
  1922.      null value, because the `vi' editor assumes that insertion of a
  1923.      character is impossible if `im' is not provided.
  1924.  
  1925.      New programs should not act like `vi'.  They should pay attention
  1926.      to `im' only if it is defined.
  1927.  
  1928. `ei'
  1929.      String of commands to leave insert mode.  This capability must be
  1930.      present if `im' is.
  1931.  
  1932.      On a few old terminals the same string is used to enter and exit
  1933.      insert mode.  This string turns insert mode on if it was off, and off
  1934.      it it was on.  You can tell these terminals because the `ei'
  1935.      string equals the `im' string.  If you want to support these
  1936.      terminals, you must always remember accurately whether insert mode is
  1937.      in effect.  However, these terminals are obsolete, and it is
  1938.      reasonable to refuse to support them.  On all modern terminals, you
  1939.      can safely output `ei' at any time to ensure that insert mode is
  1940.      turned off.
  1941.  
  1942. `ic'
  1943.      String of commands to insert one character position at the cursor.
  1944.      The cursor does not move.
  1945.  
  1946.      If outputting a graphic character while in insert mode is sufficient
  1947.      to insert the character, then the `ic' capability should be
  1948.      defined with a null value.
  1949.  
  1950.      If your terminal offers a choice of ways to insert---either use insert
  1951.      mode or use a special command---then define `im' and do not define
  1952.      `ic', since this gives the most efficient operation when several
  1953.      characters are to be inserted.  *Do not* define both strings, for
  1954.      that means that *both* must be used each time insertion is done.
  1955.  
  1956. `ip'
  1957.      String of commands to output following an inserted graphic character
  1958.      in insert mode.  Often it is used just for a padding spec, when padding
  1959.      is needed after an inserted character (*Note Padding::).
  1960.  
  1961. `IC'
  1962.      String of commands to insert N character positions at and after
  1963.      the cursor.  It has the same effect as repeating the `ic' string
  1964.      and a space, N times.
  1965.  
  1966.      If `IC' is provided, application programs may use it without first
  1967.      entering insert mode.
  1968.  
  1969. `mi'
  1970.      Flag whose presence means it is safe to move the cursor while in insert
  1971.      mode and assume the terminal remains in insert mode.
  1972.  
  1973. `in'
  1974.      Flag whose presence means that the terminal distinguishes between
  1975.      character positions in which space characters have been output and
  1976.      positions which have been cleared.
  1977.  
  1978. An application program can assume that the terminal can do character
  1979. insertion if *any one of* the capabilities `IC', `im',
  1980. `ic' or `ip' is provided.
  1981.  
  1982. To insert N blank character positions, move the cursor to the place
  1983. to insert them and follow this algorithm:
  1984.  
  1985.   1. If an `IC' string is provided, output it with parameter N
  1986.      and you are finished.  Otherwise (or if you don't want to bother to
  1987.      look for an `IC' string) follow the remaining steps.
  1988.  
  1989.   2. Output the `im' string, if there is one, unless the terminal is
  1990.      already in insert mode.
  1991.  
  1992.   3. Repeat steps 4 through 6, N times.
  1993.  
  1994.   4. Output the `ic' string if any.
  1995.  
  1996.   5. Output a space.
  1997.  
  1998.   6. Output the `ip' string if any.
  1999.  
  2000.   7. Output the `ei' string, eventually, to exit insert mode.  There
  2001.      is no need to do this right away.  If the `mi' flag is present,
  2002.      you can move the cursor and the cursor will remain in insert mode;
  2003.      then you can do more insertion elsewhere without reentering insert
  2004.      mode.
  2005.  
  2006. To insert N graphic characters, position the cursor and follow this
  2007. algorithm:
  2008.  
  2009.   1. If an `IC' string is provided, output it with parameter N,
  2010.      then output the graphic characters, and you are finished.  Otherwise
  2011.      (or if you don't want to bother to look for an `IC' string)
  2012.      follow the remaining steps.
  2013.  
  2014.   2. Output the `im' string, if there is one, unless the terminal is
  2015.      already in insert mode.
  2016.  
  2017.   3. For each character to be output, repeat steps 4 through 6.
  2018.  
  2019.   4. Output the `ic' string if any.
  2020.  
  2021.   5. Output the next graphic character.
  2022.  
  2023.   6. Output the `ip' string if any.
  2024.  
  2025.   7. Output the `ei' string, eventually, to exit insert mode.  There
  2026.      is no need to do this right away.  If the `mi' flag is present,
  2027.      you can move the cursor and the cursor will remain in insert mode;
  2028.      then you can do more insertion elsewhere without reentering insert
  2029.      mode.
  2030.  
  2031. Note that this is not the same as the original Unix termcap specifications
  2032. in one respect: it assumes that the `IC' string can be used without
  2033. entering insert mode.  This is true as far as I know, and it allows you be
  2034. able to avoid entering and leaving insert mode, and also to be able to
  2035. avoid the inserted-character padding after the characters that go into the
  2036. inserted positions.
  2037.  
  2038. Deletion of characters is less complicated; deleting one column is done by
  2039. outputting the `dc' string.  However, there may be a delete mode that
  2040. must be entered with `dm' in order to make `dc' work.
  2041.  
  2042. `dc'
  2043.      String of commands to delete one character position at the cursor.  If
  2044.      `dc' is not present, the terminal cannot delete characters.
  2045.  
  2046. `DC'
  2047.      String of commands to delete N characters starting at the cursor.
  2048.      It has the same effect as repeating the `dc' string N times.
  2049.      Any terminal description that has `DC' also has `dc'.
  2050.  
  2051. `dm'
  2052.      String of commands to enter delete mode.  If not present, there is no
  2053.      delete mode, and `dc' can be used at any time (assuming there is
  2054.      a `dc').
  2055.  
  2056. `ed'
  2057.      String of commands to exit delete mode.  This must be present if
  2058.      `dm' is.
  2059.  
  2060. To delete N character positions, position the cursor and follow these
  2061. steps:
  2062.  
  2063.   1. If the `DC' string is present, output it with parameter N
  2064.      and you are finished.  Otherwise, follow the remaining steps.
  2065.  
  2066.   2. Output the `dm' string, unless you know the terminal is already
  2067.      in delete mode.
  2068.  
  2069.   3. Output the `dc' string N times.
  2070.  
  2071.   4. Output the `ed' string eventually.  If the flag capability
  2072.      `mi' is present, you can move the cursor and do more deletion
  2073.      without leaving and reentering delete mode.
  2074.  
  2075. As with the `IC' string, we have departed from the original termcap
  2076. specifications by assuming that `DC' works without entering delete
  2077. mode even though `dc' would not.
  2078.  
  2079. If the `dm' and `im' capabilities are both present and have the
  2080. same value, it means that the terminal has one mode for both insertion and
  2081. deletion.  It is useful for a program to know this, because then it can do
  2082. insertions after deletions, or vice versa, without leaving insert/delete
  2083. mode and reentering it.
  2084.  
  2085.  
  2086. File: termcap  Node: Standout, Prev: Insdel Char, Up: Capabilities, Next: Underlining
  2087.  
  2088. Standout and Appearance Modes
  2089. =============================
  2090.  
  2091. "Appearance modes" are modifications to the ways characters are
  2092. displayed.  Typical appearance modes include reverse video, dim, bright,
  2093. blinking, underlined, invisible, and alternate character set.  Each kind of
  2094. terminal supports various among these, or perhaps none.
  2095.  
  2096. For each type of terminal, one appearance mode or combination of them that
  2097. looks good for highlighted text is chosen as the "standout mode".  The
  2098. capabilities `so' and `se' say how to enter and leave standout
  2099. mode.  Programs that use appearance modes only to highlight some text
  2100. generally use the standout mode so that they can work on as many terminals
  2101. as possible.  Use of specific appearance modes other than "underlined"
  2102. and "alternate character set" is rare.
  2103.  
  2104. Terminals that implement appearance modes fall into two general classes as
  2105. to how they do it.
  2106.  
  2107. In some terminals, the presence or absence of any appearance mode is
  2108. recorded separately for each character position.  In these terminals, each
  2109. graphic character written is given the appearance modes current at the time
  2110. it is written, and keeps those modes until it is erased or overwritten.
  2111. There are special commands to turn the appearance modes on or off for
  2112. characters to be written in the future.
  2113.  
  2114. In other terminals, the change of appearance modes is represented by a
  2115. marker that belongs to a certain screen position but affects all following
  2116. screen positions until the next marker.  These markers are traditionally
  2117. called "magic cookies".
  2118.  
  2119. The same capabilities (`so', `se', `mb' and so on) for
  2120. turning appearance modes on and off are used for both magic-cookie
  2121. terminals and per-character terminals.  On magic cookie terminals, these
  2122. give the commands to write the magic cookies.  On per-character terminals,
  2123. they change the current modes that affect future output and erasure.  Some
  2124. simple applications can use these commands without knowing whether or not
  2125. they work by means of cookies.
  2126.  
  2127. However, a program that maintains and updates a display needs to know
  2128. whether the terminal uses magic cookies, and exactly what their effect is.
  2129. This information comes from the `sg' capability.
  2130.  
  2131. The `sg' capability is a numeric capability whose presence indicates
  2132. that the terminal uses magic cookies for appearance modes.  Its value is
  2133. the number of character positions that a magic cookie occupies.  Usually
  2134. the cookie occupies one or more character positions on the screen, and these
  2135. character positions are displayed as blank, but in some terminals the
  2136. cookie has zero width.
  2137.  
  2138. The `sg' capability describes both the magic cookie to turn standout
  2139. on and the cookie to turn it off.  This makes the assumption that both
  2140. kinds of cookie have the same width on the screen.  If that is not true,
  2141. the narrower cookie must be "widened" with spaces until it has the same
  2142. width as the other.
  2143.  
  2144. On some magic cookie terminals, each line always starts with normal
  2145. display; in other words, the scope of a magic cookie never extends over
  2146. more than one line.  But on other terminals, one magic cookie affects all
  2147. the lines below it unless explicitly canceled.  Termcap does not define any
  2148. way to distinguish these two ways magic cookies can work.  To be safe, it
  2149. is best to put a cookie at the beginning of each line.
  2150.  
  2151. On some per-character terminals, standout mode or other appearance modes
  2152. may be canceled by moving the cursor.  On others, moving the cursor has no
  2153. effect on the state of the appearance modes.  The latter class of terminals
  2154. are given the flag capability `ms' ("can move in standout").  All
  2155. programs that might have occasion to move the cursor while appearance modes
  2156. are turned on must check for this flag; if it is not present, they should
  2157. reset appearance modes to normal before doing cursor motion.
  2158.  
  2159. A program that has turned on only standout mode should use `se' to
  2160. reset the standout mode to normal.  A program that has turned on only
  2161. alternate character set mode should use `ae' to return it to normal.
  2162. If it is possible that any other appearance modes are turned on, use the
  2163. `me' capability to return them to normal.
  2164.  
  2165. Note that the commands to turn on one appearance mode, including `so'
  2166. and `mb' ... `mr', if used while some other appearance modes
  2167. are turned on, may combine the two modes on some terminals but may turn off
  2168. the mode previously enabled on other terminals.  This is because some
  2169. terminals do not have a command to set or clear one appearance mode without
  2170. changing the others.  Programs should not attempt to use appearance modes
  2171. in combination except with `sa', and when switching from one single
  2172. mode to another should always turn off the previously enabled mode and then
  2173. turn on the new desired mode.
  2174.  
  2175. On some old terminals, the `so' and `se' commands may be the same
  2176. command, which has the effect of turning standout on if it is off, or off
  2177. it is on.  It is therefore risky for a program to output extra `se'
  2178. commands for good measure.  Fortunately, all these terminals are obsolete.
  2179.  
  2180. Programs that update displays in which standout-text may be replaced with
  2181. non-standout text must check for the `xs' flag.  In a per-character
  2182. terminal, this flag says that the only way to remove standout once written is
  2183. to clear that portion of the line with the `ce' string or something
  2184. even more powerful (*Note Clearing::); just writing new characters at those
  2185. screen positions will not change the modes in effect there.  In a magic
  2186. cookie terminal, `xs' says that the only way to remove a cookie is to
  2187. clear a portion of the line that includes the cookie; writing a different
  2188. cookie at the same position does not work.
  2189.  
  2190. Such programs must also check for the `xt' flag, which means that the
  2191. terminal is a Teleray 1061.  On this terminal it is impossible to position
  2192. the cursor at the front of a magic cookie, so the only two ways to remove a
  2193. cookie are (1) to delete the line it is on or (2) to position the cursor at
  2194. least one character before it (possibly on a previous line) and output the
  2195. `se' string, which on these terminals finds and removes the next
  2196. `so' magic cookie on the screen.  (It may also be possible to remove a
  2197. cookie which is not at the beginning of a line by clearing that line.)  The
  2198. `xt' capability also has implications for the use of tab characters,
  2199. but in that regard it is obsolete (*Note Cursor Motion::).
  2200.  
  2201. `so'
  2202.      String of commands to enter standout mode.
  2203.  
  2204. `se'
  2205.      String of commands to leave standout mode.
  2206.  
  2207. `sg'
  2208.      Numeric capability, the width on the screen of the magic cookie.  This
  2209.      capability is absent in terminals that record appearance modes
  2210.      character by character.
  2211.  
  2212. `ms'
  2213.      Flag whose presence means that it is safe to move the cursor while the
  2214.      appearance modes are not in the normal state.  If this flag is absent,
  2215.      programs should always reset the appearance modes to normal before
  2216.      moving the cursor.
  2217.  
  2218. `xs'
  2219.      Flag whose presence means that the only way to reset appearance modes
  2220.      already on the screen is to clear to end of line.  On a per-character
  2221.      terminal, you must clear the area where the modes are set.  On a magic
  2222.      cookie terminal, you must clear an area containing the cookie.
  2223.      See the discussion above.
  2224.  
  2225. `xt'
  2226.      Flag whose presence means that the cursor cannot be positioned right
  2227.      in front of a magic cookie, and that `se' is a command to delete
  2228.      the next magic cookie following the cursor.  See discussion above.
  2229.  
  2230. `mb'
  2231.      String of commands to enter blinking mode.
  2232.  
  2233. `md'
  2234.      String of commands to enter double-bright mode.
  2235.  
  2236. `mh'
  2237.      String of commands to enter half-bright mode.
  2238.  
  2239. `mk'
  2240.      String of commands to enter invisible mode.
  2241.  
  2242. `mp'
  2243.      String of commands to enter protected mode.
  2244.  
  2245. `mr'
  2246.      String of commands to enter reverse-video mode.
  2247.  
  2248. `me'
  2249.      String of commands to turn off all appearance modes, including
  2250.      standout mode and underline mode.  On some terminals it also turns off
  2251.      alternate character set mode; on others, it may not.  This capability
  2252.      must be present if any of `mb' ... `mr' is present.
  2253.  
  2254. `as'
  2255.      String of commands to turn on alternate character set mode.  This mode
  2256.      assigns some or all graphic characters an alternate picture on the
  2257.      screen.  There is no standard as to what the alternate pictures look
  2258.      like.
  2259.  
  2260. `ae'
  2261.      String of commands to turn off alternate character set mode.
  2262.  
  2263. `sa'
  2264.      String of commands to turn on an arbitrary combination of appearance
  2265.      modes.  It accepts 9 parameters, each of which controls a particular
  2266.      kind of appearance mode.  A parameter should be 1 to turn its appearance
  2267.      mode on, or zero to turn that mode off.  Most terminals do not support
  2268.      the `sa' capability, even among those that do have various
  2269.      appearance modes.
  2270.  
  2271.      The nine parameters are, in order, STANDOUT, UNDERLINE,
  2272.      REVERSE, BLINK, HALF-BRIGHT, DOUBLE-BRIGHT,
  2273.      BLANK, PROTECT, ALT CHAR SET.
  2274.  
  2275.  
  2276. File: termcap  Node: Underlining, Prev: Standout, Up: Capabilities, Next: Cursor Visibility
  2277.  
  2278. Underlining
  2279. ===========
  2280.  
  2281. Underlining on most terminals is a kind of appearance mode, much like
  2282. standout mode.  Therefore, it may be implemented using magic cookies or as
  2283. a flag in the terminal whose current state affects each character that is
  2284. output.  *Note Standout::, for a full explanation.
  2285.  
  2286. The `ug' capability is a numeric capability whose presence indicates
  2287. that the terminal uses magic cookies for underlining.  Its value is the
  2288. number of character positions that a magic cookie for underlining occupies;
  2289. it is used for underlining just as `sg' is used for standout.  Aside
  2290. from the simplest applications, it is impossible to use underlining
  2291. correctly without paying attention to the value of `ug'.
  2292.  
  2293. `us'
  2294.      String of commands to turn on underline mode or to output a magic cookie
  2295.      to start underlining.
  2296.  
  2297. `ue'
  2298.      String of commands to turn off underline mode or to output a magic
  2299.      cookie to stop underlining.
  2300.  
  2301. `ug'
  2302.      Width of magic cookie that represents a change of underline mode;
  2303.      or missing, if the terminal does not use a magic cookie for this.
  2304.  
  2305. `ms'
  2306.      Flag whose presence means that it is safe to move the cursor while the
  2307.      appearance modes are not in the normal state.  Underlining is an
  2308.      appearance mode.  If this flag is absent, programs should always turn
  2309.      off underlining before moving the cursor.
  2310.  
  2311. There are two other, older ways of doing underlining: there can be a
  2312. command to underline a single character, or the output of `_', the
  2313. ASCII underscore character, as an overstrike could cause a character to be
  2314. underlined.  New programs need not bother to handle these capabilities
  2315. unless the author cares strongly about the obscure terminals which support
  2316. them.  However, terminal descriptions should provide these capabilities
  2317. when appropriate.
  2318.  
  2319. `uc'
  2320.      String of commands to underline the character under the cursor, and
  2321.      move the cursor right.
  2322.  
  2323. `ul'
  2324.      Flag whose presence means that the terminal can underline by
  2325.      overstriking an underscore character (`_'); some terminals can do
  2326.      this even though they do not support overstriking in general.  An
  2327.      implication of this flag is that when outputting new text to overwrite
  2328.      old text, underscore characters must be treated specially lest they
  2329.      underline the old text instead.
  2330.  
  2331.  
  2332.  
  2333. File: termcap  Node: Cursor Visibility, Prev: Underlining, Up: Capabilities, Next: Bell
  2334.  
  2335. Cursor Visibility
  2336. =================
  2337.  
  2338. Some terminals have the ability to make the cursor invisible, or to enhance
  2339. it.  Enhancing the cursor is often done by programs that plan to use the
  2340. cursor to indicate to the user a position of interest that may be anywhere
  2341. on the screen---for example, the Emacs editor enhances the cursor on entry.
  2342. Such programs should always restore the cursor to normal on exit.
  2343.  
  2344. `vs'
  2345.      String of commands to enhance the cursor.
  2346.  
  2347. `vi'
  2348.      String of commands to make the cursor invisible.
  2349.  
  2350. `ve'
  2351.      String of commands to return the cursor to normal.
  2352.  
  2353. If you define either `vs' or `vi', you must also define `ve'.
  2354.  
  2355.  
  2356. File: termcap  Node: Bell, Prev: Cursor Visibility, Up: Capabilities, Next: Keypad
  2357.  
  2358. Bell
  2359. ====
  2360.  
  2361. Here we describe commands to make the terminal ask for the user to pay
  2362. attention to it.
  2363.  
  2364. `bl'
  2365.      String of commands to cause the terminal to make an audible sound.  If
  2366.      this capability is absent, the terminal has no way to make a suitable
  2367.      sound.
  2368.  
  2369. `vb'
  2370.      String of commands to cause the screen to flash to attract attention
  2371.      ("visible bell").  If this capability is absent, the terminal has no
  2372.      way to do such a thing.
  2373.  
  2374.  
  2375. File: termcap  Node: Keypad, Prev: Bell, Up: Capabilities, Next: Meta Key
  2376.  
  2377. Keypad and Function Keys
  2378. ========================
  2379.  
  2380. Many terminals have arrow and function keys that transmit specific
  2381. character sequences to the computer.  Since the precise sequences used
  2382. depend on the terminal, termcap defines capabilities used to say what the
  2383. sequences are.  Unlike most termcap string-valued capabilities, these are
  2384. not strings of commands to be sent to the terminal, rather strings that
  2385. are received from the terminal.
  2386.  
  2387. Programs that expect to use keypad keys should check, initially, for a
  2388. `ks' capability and send it, to make the keypad actually transmit.
  2389. Such programs should also send the `ke' string when exiting.
  2390.  
  2391. `ks'
  2392.      String of commands to make the function keys transmit.  If this
  2393.      capability is not provided, but the others in this section are,
  2394.      programs may assume that the function keys always transmit.
  2395.  
  2396. `ke'
  2397.      String of commands to make the function keys work locally.  This
  2398.      capability is provided only if `ks' is.
  2399.  
  2400. `kl'
  2401.      String of input characters sent by typing the left-arrow key.  If this
  2402.      capability is missing, you cannot expect the terminal to have a
  2403.      left-arrow key that transmits anything to the computer.
  2404.  
  2405. `kr'
  2406.      String of input characters sent by typing the right-arrow key.
  2407.  
  2408. `ku'
  2409.      String of input characters sent by typing the up-arrow key.
  2410.  
  2411. `kd'
  2412.      String of input characters sent by typing the down-arrow key.
  2413.  
  2414. `kh'
  2415.      String of input characters sent by typing the "home-position" key.
  2416.  
  2417. `K1' ... `K5'
  2418.      Strings of input characters sent by the five other keys in a 3-by-3
  2419.      array that includes the arrow keys, if the keyboard has such a 3-by-3
  2420.      array.  Note that one of these keys may be the "home-position" key,
  2421.      in which case one of these capabilities will have the same value as
  2422.      the `kh' key.
  2423.  
  2424. `k0'
  2425.      String of input characters sent by function key 10 (or 0, if the terminal
  2426.      has one labeled 0).
  2427.  
  2428. `k1' ... `k9'
  2429.      Strings of input characters sent by function keys 1 through 9,
  2430.      provided for those function keys that exist.
  2431.  
  2432. `kn'
  2433.      Number: the number of numbered function keys, if there are more than
  2434.      10.
  2435.  
  2436. `l0' ... `l9'
  2437.      Strings which are the labels appearing on the keyboard on the keys
  2438.      described by the capabilities `k0' ... `l9'.  These capabilities
  2439.      should be left undefined if the labels are `f0' or `f10' and `f1'
  2440.      ... `f9'.
  2441.  
  2442. `kH'
  2443.      String of input characters sent by the "home down" key, if there is
  2444.      one.
  2445.  
  2446. `kb'
  2447.      String of input characters sent by the "backspace" key, if there is
  2448.      one.
  2449.  
  2450. `ka'
  2451.      String of input characters sent by the "clear all tabs" key, if there
  2452.      is one.
  2453.  
  2454. `kt'
  2455.      String of input characters sent by the "clear tab stop this column"
  2456.      key, if there is one.
  2457.  
  2458. `kC'
  2459.      String of input characters sent by the "clear screen" key, if there is
  2460.      one.
  2461.  
  2462. `kD'
  2463.      String of input characters sent by the "delete character" key, if
  2464.      there is one.
  2465.  
  2466. `kL'
  2467.      String of input characters sent by the "delete line" key, if there is
  2468.      one.
  2469.  
  2470. `kM'
  2471.      String of input characters sent by the "exit insert mode" key, if
  2472.      there is one.
  2473.  
  2474. `kE'
  2475.      String of input characters sent by the "clear to end of line" key, if
  2476.      there is one.
  2477.  
  2478. `kS'
  2479.      String of input characters sent by the "clear to end of screen" key,
  2480.      if there is one.
  2481.  
  2482. `kI'
  2483.      String of input characters sent by the "insert character" or "enter
  2484.      insert mode" key, if there is one.
  2485.  
  2486. `kA'
  2487.      String of input characters sent by the "insert line" key, if there is
  2488.      one.
  2489.  
  2490. `kN'
  2491.      String of input characters sent by the "next page" key, if there is
  2492.      one.
  2493.  
  2494. `kP'
  2495.      String of input characters sent by the "previous page" key, if there is
  2496.      one.
  2497.  
  2498. `kF'
  2499.      String of input characters sent by the "scroll forward" key, if there
  2500.      is one.
  2501.  
  2502. `kR'
  2503.      String of input characters sent by the "scroll reverse" key, if there
  2504.      is one.
  2505.  
  2506. `kT'
  2507.      String of input characters sent by the "set tab stop in this column"
  2508.      key, if there is one.
  2509.  
  2510. `ko'
  2511.      String listing the other function keys the terminal has.  This is a
  2512.      very obsolete way of describing the same information found in the
  2513.      `kH' ... `kT' keys.  The string contains a list of two-character
  2514.      termcap capability names, separated by commas.  The meaning is that
  2515.      for each capability name listed, the terminal has a key which sends
  2516.      the string which is the value of that capability.  For example, the
  2517.      value `:ko=cl,ll,sf,sr:' says that the terminal has four function
  2518.      keys which mean "clear screen", "home down", "scroll forward" and
  2519.      "scroll reverse".
  2520.  
  2521.  
  2522. File: termcap  Node: Meta Key, Prev: Keypad, Up: Capabilities, Next: Initialization
  2523.  
  2524. Meta Key
  2525. ========
  2526.  
  2527. A Meta key is a key on the keyboard that modifies each character you type
  2528. by controlling the 0200 bit.  This bit is on if and only if the Meta key is
  2529. held down when the character is typed.  Characters typed using the Meta key
  2530. are called Meta characters.  Emacs uses Meta characters as editing
  2531. commands.
  2532.  
  2533. `km'
  2534.      Flag whose presence means that the terminal has a Meta key.
  2535.  
  2536. `mm'
  2537.      String of commands to enable the functioning of the Meta key.
  2538.  
  2539. `mo'
  2540.      String of commands to disable the functioning of the Meta key.
  2541.  
  2542. If the terminal has `km' but does not have `mm' and `mo', it
  2543. means that the Meta key always functions.  If it has `mm' and
  2544. `mo', it means that the Meta key can be turned on or off.  Send the
  2545. `mm' string to turn it on, and the `mo' string to turn it off.
  2546. I do not know why one would ever not want it to be on.
  2547.  
  2548.  
  2549. File: termcap  Node: Initialization, Prev: Meta Key, Up: Capabilities, Next: Pad Specs
  2550.  
  2551. Initialization
  2552. ==============
  2553.  
  2554. `ti'
  2555.      String of commands to put the terminal into whatever special modes are
  2556.      needed or appropriate for programs that move the cursor
  2557.      nonsequentially around the screen.  Programs that use termcap to do
  2558.      full-screen display should output this string when they start up.
  2559.  
  2560. `te'
  2561.      String of commands to undo what is done by the `ti' string.
  2562.      Programs that output the `ti' string on entry should output this
  2563.      string when they exit.
  2564.  
  2565. `is'
  2566.      String of commands to initialize the terminal for each login session.
  2567.  
  2568. `if'
  2569.      String which is the name of a file containing the string of commands
  2570.      to initialize the terminal for each session of use.  Normally `is'
  2571.      and `if' are not both used.
  2572.  
  2573. `i1'
  2574. `i3'
  2575.      Two more strings of commands to initialize the terminal for each login
  2576.      session.  The `i1' string (if defined) is output before `is'
  2577.      or `if', and the `i3' string (if defined) is output after.
  2578.  
  2579.      The reason for having three separate initialization strings is to make
  2580.      it easier to define a group of related terminal types with slightly
  2581.      different initializations.  Define two or three of the strings in the
  2582.      basic type; then the other types can override one or two of the
  2583.      strings.
  2584.  
  2585. `rs'
  2586.      String of commands to reset the terminal from any strange mode it may
  2587.      be in.  Normally this includes the `is' string (or other commands
  2588.      with the same effects) and more.  What would go in the `rs'
  2589.      string but not in the `is' string are annoying or slow commands
  2590.      to bring the terminal back from strange modes that nobody would
  2591.      normally use.
  2592.  
  2593. `it'
  2594.      Numeric value, the initial spacing between hardware tab stop columns
  2595.      when the terminal is powered up.  Programs to initialize the terminal
  2596.      can use this to decide whether there is a need to set the tab stops.
  2597.      If the initial width is 8, well and good; if it is not 8, then the
  2598.      tab stops should be set; if they cannot be set, the kernel is told
  2599.      to convert tabs to spaces, and other programs will observe this and do
  2600.      likewise.
  2601.  
  2602. `ct'
  2603.      String of commands to clear all tab stops.
  2604.  
  2605. `st'
  2606.      String of commands to set tab stop at current cursor column on all
  2607.      lines.
  2608.  
  2609.  
  2610. File: termcap  Node: Pad Specs, Prev: Initialization, Up: Capabilities, Next: Status Line
  2611.  
  2612. Padding Capabilities
  2613. ====================
  2614.  
  2615. There are two terminal capabilities that exist just to explain the proper
  2616. way to obey the padding specifications in all the command string
  2617. capabilities.  One, `pc', must be obeyed by all termcap-using
  2618. programs.
  2619.  
  2620. `pb'
  2621.      Numeric value, the lowest baud rate at which padding is actually
  2622.      needed.  Programs may check this and refrain from doing any padding at
  2623.      lower speeds.
  2624.  
  2625. `pc'
  2626.      String of commands for padding.  The first character of this string is
  2627.      to be used as the pad character, instead of using null characters for
  2628.      padding.  If `pc' is not provided, use null characters.  Every
  2629.      program that uses termcap must look up this capability and use it to
  2630.      set the variable `PC' that is used by `tputs'.
  2631.      *Note Padding::.
  2632.  
  2633. Some termcap capabilities exist just to specify the amount of padding that
  2634. the kernel should give to cursor motion commands used in ordinary
  2635. sequential output.
  2636.  
  2637. `dC'
  2638.      Numeric value, the number of msec of padding needed for the
  2639.      carriage-return character.
  2640.  
  2641. `dN'
  2642.      Numeric value, the number of msec of padding needed for the newline
  2643.      (linefeed) character.
  2644.  
  2645. `dB'
  2646.      Numeric value, the number of msec of padding needed for the backspace
  2647.      character.
  2648.  
  2649. `dF'
  2650.      Numeric value, the number of msec of padding needed for the formfeed
  2651.      character.
  2652.  
  2653. `dT'
  2654.      Numeric value, the number of msec of padding needed for the tab
  2655.      character.
  2656.  
  2657. In some systems, the kernel uses the above capabilities; in other systems,
  2658. the kernel uses the paddings specified in the string capabilities
  2659. `cr', `sf', `le', `ff' and `ta'.  Descriptions of
  2660. terminals which require such padding should contain the `dC' ...
  2661. `dT' capabilities and also specify the appropriate padding in the
  2662. corresponding string capabilities.  Since no modern terminals require
  2663. padding for ordinary sequential output, you probably won't need to do
  2664. either of these things.
  2665.  
  2666.  
  2667. File: termcap  Node: Status Line, Prev: Pad Specs, Up: Capabilities, Next: Half-Line
  2668.  
  2669. Status Line
  2670. ===========
  2671.  
  2672. A "status line" is a line on the terminal that is not used for ordinary
  2673. display output but instead used for a special message.  The intended use is
  2674. for a continuously updated description of what the user's program is doing,
  2675. and that is where the name "status line" comes from, but in fact it could
  2676. be used for anything.  The distinguishing characteristic of a status line
  2677. is that ordinary output to the terminal does not affect it; it changes only
  2678. if the special status line commands of this section are used.
  2679.  
  2680. `hs'
  2681.      Flag whose presence means that the terminal has a status line.  If a
  2682.      terminal description specifies that there is a status line, it must
  2683.      provide the `ts' and `fs' capabilities.
  2684.  
  2685. `ts'
  2686.      String of commands to move the terminal cursor into the status line.
  2687.      Usually these commands must specifically record the old cursor
  2688.      position for the sake of the `fs' string.
  2689.  
  2690. `fs'
  2691.      String of commands to move the cursor back from the status line to its
  2692.      previous position (outside the status line).
  2693.  
  2694. `es'
  2695.      Flag whose presence means that other display commands work while
  2696.      writing the status line.  In other words, one can clear parts of it,
  2697.      insert or delete characters, move the cursor within it using `ch'
  2698.      if there is a `ch' capability, enter and leave standout mode, and
  2699.      so on.
  2700.  
  2701. `ds'
  2702.      String of commands to disable the display of the status line.  This
  2703.      may be absent, if there is no way to disable the status line display.
  2704.  
  2705. `ws'
  2706.      Numeric value, the width of the status line.  If this capability is
  2707.      absent in a terminal that has a status line, it means the status line
  2708.      is the same width as the other lines.
  2709.  
  2710.      Note that the value of `ws' is sometimes as small as 8.
  2711.  
  2712.  
  2713. File: termcap  Node: Half-Line, Prev: Status Line, Up: Capabilities, Next: Printer
  2714.  
  2715. Half-Line Motion
  2716. ================
  2717.  
  2718. Some terminals have commands for moving the cursor vertically by half-lines,
  2719. useful for outputting subscripts and superscripts.  Mostly it is hardcopy
  2720. terminals that have such features.
  2721.  
  2722. `hu'
  2723.      String of commands to move the cursor up half a line.  If the terminal
  2724.      is a display, it is your responsibility to avoid moving up past the
  2725.      top line; however, most likely the terminal that supports this is a
  2726.      hardcopy terminal and there is nothing to be concerned about.
  2727.  
  2728. `hd'
  2729.      String of commands to move the cursor down half a line.  If the
  2730.      terminal is a display, it is your responsibility to avoid moving down
  2731.      past the bottom line, etc.
  2732.  
  2733.  
  2734. File: termcap  Node: Printer, Prev: Half-Line, Up: Capabilities
  2735.  
  2736. Controlling Printers Attached to Terminals
  2737. ==========================================
  2738.  
  2739. Some terminals have attached hardcopy printer ports.  They may be able to
  2740. copy the screen contents to the printer; they may also be able to redirect
  2741. output to the printer.  Termcap does not have anything to tell the program
  2742. whether the redirected output appears also on the screen; it does on some
  2743. terminals but not all.
  2744.  
  2745. `ps'
  2746.      String of commands to cause the contents of the screen to be printed.
  2747.      If it is absent, the screen contents cannot be printed.
  2748.  
  2749. `po'
  2750.      String of commands to redirect further output to the printer.
  2751.  
  2752. `pf'
  2753.      String of commands to terminate redirection of output to the printer.
  2754.      This capability must be present in the description if `po' is.
  2755.  
  2756. `pO'
  2757.      String of commands to redirect output to the printer for next N
  2758.      characters of output, regardless of what they are.  Redirection will
  2759.      end automatically after N characters of further output.  Until
  2760.      then, nothing that is output can end redirection, not even the
  2761.      `pf' string if there is one.  The number N should not be
  2762.      more than 255.
  2763.  
  2764.      One use of this capability is to send non-text byte sequences (such as
  2765.      bit-maps) to the printer.
  2766.  
  2767. Most terminals with printers do not support all of `ps', `po' and
  2768. `pO'; any one or two of them may be supported.  To make a program that
  2769. can send output to all kinds of printers, it is necessary to check for all
  2770. three of these capabilities, choose the most convenient of the ones that
  2771. are provided, and use it in its own appropriate fashion.
  2772.  
  2773.  
  2774. File: termcap  Node: Summary, Prev: Capabilities, Up: Top, Next: Var Index
  2775.  
  2776. Summary of Capability Names
  2777. ***************************
  2778.  
  2779. Here are all the terminal capability names in alphabetical order
  2780. with a brief description of each.  For cross references to their definitions,
  2781. see the index of capability names (*Note Cap Index::).
  2782.  
  2783. `ae'
  2784.      String to turn off alternate character set mode.
  2785. `al'
  2786.      String to insert a blank line before the cursor.
  2787. `AL'
  2788.      String to insert N blank lines before the cursor.
  2789. `am'
  2790.      Flag: output to last column wraps cursor to next line.
  2791. `as'
  2792.      String to turn on alternate character set mode.like.
  2793. `bc'
  2794.      Very obsolete alternative name for the `le' capability.
  2795. `bl'
  2796.      String to sound the bell.
  2797. `bs'
  2798.      Obsolete flag: ASCII backspace may be used for leftward motion.
  2799. `bt'
  2800.      String to move the cursor left to the previous hardware tab stop column.
  2801. `bw'
  2802.      Flag: `le' at left margin wraps to end of previous line.
  2803. `CC'
  2804.      String to change terminal's command character.
  2805. `cd'
  2806.      String to clear the line the cursor is on, and following lines.
  2807. `ce'
  2808.      String to clear from the cursor to the end of the line.
  2809. `ch'
  2810.      String to position the cursor at column C in the same line.
  2811. `cl'
  2812.      String to clear the entire screen and put cursor at upper left corner.
  2813. `cm'
  2814.      String to position the cursor at line L, column C.
  2815. `CM'
  2816.      String to position the cursor at line L, column
  2817.      C, relative to display memory.
  2818. `co'
  2819.      Number: width of the screen.
  2820. `cr'
  2821.      String to move cursor sideways to left margin.
  2822. `cs'
  2823.      String to set the scroll region.
  2824. `cS'
  2825.      Alternate form of string to set the scroll region.
  2826. `ct'
  2827.      String to clear all tab stops.
  2828. `cv'
  2829.      String to position the cursor at line L in the same column.
  2830. `da'
  2831.      Flag: data scrolled off top of screen may be scrolled back.
  2832. `db'
  2833.      Flag: data scrolled off bottom of screen may be scrolled back.
  2834. `dB'
  2835.      Obsolete number: msec of padding needed for the backspace character.
  2836. `dc'
  2837.      String to delete one character position at the cursor.
  2838. `dC'
  2839.      Obsolete number: msec of padding needed for the carriage-return character.
  2840. `DC'
  2841.      String to delete N characters starting at the cursor.
  2842. `dF'
  2843.      Obsolete number: msec of padding needed for the formfeed character.
  2844. `dl'
  2845.      String to delete the line the cursor is on.
  2846. `DL'
  2847.      String to delete N lines starting with the cursor's line.
  2848. `dm'
  2849.      String to enter delete mode.
  2850. `dN'
  2851.      Obsolete number: msec of padding needed for the newline character.
  2852. `do'
  2853.      String to move the cursor vertically down one line.
  2854. `DO'
  2855.      String to move cursor vertically down N lines.
  2856. `ds'
  2857.      String to disable the display of the status line.
  2858. `dT'
  2859.      Obsolete number: msec of padding needed for the tab character.
  2860. `ec'
  2861.      String of commands to clear N characters at cursor.
  2862. `ed'
  2863.      String to exit delete mode.
  2864. `ei'
  2865.      String to leave insert mode.
  2866. `eo'
  2867.      Flag: output of a space can erase an overstrike.
  2868. `es'
  2869.      Flag: other display commands work while writing the status line.
  2870. `ff'
  2871.      String to advance to the next page, for a hardcopy terminal.
  2872. `fs'
  2873.      String to move the cursor back from the status line to its
  2874.      previous position (outside the status line).
  2875. `gn'
  2876.      Flag: this terminal type is generic, not real.
  2877. `hc'
  2878.      Flag: hardcopy terminal.
  2879. `hd'
  2880.      String to move the cursor down half a line.
  2881. `ho'
  2882.      String to position cursor at upper left corner.
  2883. `hs'
  2884.      Flag: the terminal has a status line.
  2885. `hu'
  2886.      String to move the cursor up half a line.
  2887. `hz'
  2888.      Flag: terminal cannot accept `~' as output.
  2889. `i1'
  2890.      String to initialize the terminal for each login session.
  2891. `i3'
  2892.      String to initialize the terminal for each login session.
  2893. `ic'
  2894.      String to insert one character position at the cursor.
  2895. `IC'
  2896.      String to insert N character positions at the cursor.
  2897. `if'
  2898.      String naming a file of commands to initialize the terminal.
  2899. `im'
  2900.      String to enter insert mode.
  2901. `in'
  2902.      Flag: outputting a space is different from moving over empty positions.
  2903. `ip'
  2904.      String to output following an inserted character in insert mode.
  2905. `is'
  2906.      String to initialize the terminal for each login session.
  2907. `it'
  2908.      Number: initial spacing between hardware tab stop columns.
  2909. `k0'
  2910.      String of input sent by function key 0 or 10.
  2911. `k1 ... k9'
  2912.      Strings of input sent by function keys 1 through 9.
  2913. `K1 ... K5'
  2914.      Strings sent by the five other keys in 3-by-3 array with arrows.
  2915. `ka'
  2916.      String of input sent by the "clear all tabs" key.
  2917. `kA'
  2918.      String of input sent by the "insert line" key.
  2919. `kb'
  2920.      String of input sent by the "backspace" key.
  2921. `kC'
  2922.      String of input sent by the "clear screen" key.
  2923. `kd'
  2924.      String of input sent by typing the down-arrow key.
  2925. `kD'
  2926.      String of input sent by the "delete character" key.
  2927. `ke'
  2928.      String to make the function keys work locally.
  2929. `kE'
  2930.      String of input sent by the "clear to end of line" key.
  2931. `kF'
  2932.      String of input sent by the "scroll forward" key.
  2933. `kh'
  2934.      String of input sent by typing the "home-position" key.
  2935. `kH'
  2936.      String of input sent by the "home down" key.
  2937. `kI'
  2938.      String of input sent by the "insert character" or "enter
  2939.      insert mode" key.
  2940. `kl'
  2941.      String of input sent by typing the left-arrow key.
  2942. `kL'
  2943.      String of input sent by the "delete line" key.
  2944. `km'
  2945.      Flag: the terminal has a Meta key.
  2946. `kM'
  2947.      String of input sent by the "exit insert mode" key.
  2948. `kn'
  2949.      Numeric value, the number of numbered function keys.
  2950. `kN'
  2951.      String of input sent by the "next page" key.
  2952. `ko'
  2953.      Very obsolete string listing the terminal's named function keys.
  2954. `kP'
  2955.      String of input sent by the "previous page" key.
  2956. `kr'
  2957.      String of input sent by typing the right-arrow key.
  2958. `kR'
  2959.      String of input sent by the "scroll reverse" key.
  2960. `ks'
  2961.      String to make the function keys transmit.
  2962. `kS'
  2963.      String of input sent by the "clear to end of screen" key.
  2964. `kt'
  2965.      String of input sent by the "clear tab stop this column" key.
  2966. `kT'
  2967.      String of input sent by the "set tab stop in this column" key.
  2968. `ku'
  2969.      String of input sent by typing the up-arrow key.
  2970. `l0'
  2971.      String on keyboard labelling function key 0 or 10.
  2972. `l1 ... l9'
  2973.      Strings on keyboard labelling function keys 1 through 9.
  2974. `le'
  2975.      String to move the cursor left one column.
  2976. `LE'
  2977.      String to move cursor left N columns.
  2978. `li'
  2979.      Number: height of the screen.
  2980. `ll'
  2981.      String to position cursor at lower left corner.
  2982. `lm'
  2983.      Number: lines of display memory.
  2984. `mb'
  2985.      String to enter blinking mode.
  2986. `md'
  2987.      String to enter double-bright mode.
  2988. `me'
  2989.      String to turn off all appearance modes
  2990. `mh'
  2991.      String to enter half-bright mode.
  2992. `mi'
  2993.      Flag: cursor motion in insert mode is safe.
  2994. `mk'
  2995.      String to enter invisible mode.
  2996. `mm'
  2997.      String to enable the functioning of the Meta key.
  2998. `mo'
  2999.      String to disable the functioning of the Meta key.
  3000. `mp'
  3001.      String to enter protected mode.
  3002. `mr'
  3003.      String to enter reverse-video mode.
  3004. `ms'
  3005.      Flag: cursor motion in standout mode is safe.
  3006. `nc'
  3007.      Obsolete flag: do not use ASCII carriage-return on this terminal.
  3008. `nd'
  3009.      String to move the cursor right one column.
  3010. `nl'
  3011.      Obsolete alternative name for the `do' and `sf' capabilities.
  3012. `ns'
  3013.      Flag: the terminal does not normally scroll for sequential output.
  3014. `nw'
  3015.      String to move to start of next line, possibly clearing rest of old line.
  3016. `os'
  3017.      Flag: terminal can overstrike.
  3018. `pb'
  3019.      Number: the lowest baud rate at which padding is actually needed.
  3020. `pc'
  3021.      String containing character for padding.
  3022. `pf'
  3023.      String to terminate redirection of output to the printer.
  3024. `po'
  3025.      String to redirect further output to the printer.
  3026. `pO'
  3027.      String to redirect N characters ofoutput to the printer.
  3028. `ps'
  3029.      String to print the screen on the attached printer.
  3030. `rc'
  3031.      String to move to last saved cursor position.
  3032. `RI'
  3033.      String to move cursor right N columns.
  3034. `rp'
  3035.      String to output character C repeated N times.
  3036. `rs'
  3037.      String to reset the terminal from any strange modes.
  3038. `sa'
  3039.      String to turn on an arbitrary combination of appearance modes.
  3040. `sc'
  3041.      String to save the current cursor position.
  3042. `se'
  3043.      String to leave standout mode.
  3044. `sf'
  3045.      String to scroll the screen one line up.
  3046. `SF'
  3047.      String to scroll the screen N lines up.
  3048. `sg'
  3049.      Number: width of magic standout cookie.  Absent if magic cookies are
  3050.      not used.
  3051. `so'
  3052.      String to enter standout mode.
  3053. `sr'
  3054.      String to scroll the screen one line down.
  3055. `SR'
  3056.      String to scroll the screen N line down.
  3057. `st'
  3058.      String to set tab stop at current cursor column on all lines.
  3059.      programs.
  3060. `ta'
  3061.      String to move the cursor right to the next hardware tab stop column.
  3062. `te'
  3063.      String to return terminal to settings for sequential output.
  3064. `ti'
  3065.      String to initialize terminal for random cursor motion.
  3066. `ts'
  3067.      String to move the terminal cursor into the status line.
  3068. `uc'
  3069.      String to underline one character and move cursor right.
  3070. `ue'
  3071.      String to turn off underline mode
  3072. `ug'
  3073.      Number: width of underlining magic cookie.  Absent if underlining
  3074.      doesn't use magic cookies.
  3075. `ul'
  3076.      Flag: underline by overstriking with an underscore.
  3077. `up'
  3078.      String to move the cursor vertically up one line.
  3079. `UP'
  3080.      String to move cursor vertically up N lines.
  3081. `us'
  3082.      String to turn on underline mode
  3083. `vb'
  3084.      String to make the screen flash.
  3085. `ve'
  3086.      String to return the cursor to normal.
  3087. `vi'
  3088.      String to make the cursor invisible.
  3089. `vs'
  3090.      String to enhance the cursor.
  3091. `wi'
  3092.      String to set the terminal output screen window.
  3093. `ws'
  3094.      Number: the width of the status line.
  3095. `xb'
  3096.      Flag: superbee terminal.
  3097. `xn'
  3098.      Flag: cursor wraps in a strange way.
  3099. `xs'
  3100.      Flag: clearing a line is the only way to clear the appearance modes of
  3101.      positions in that line (or, only way to remove magic cookies on that
  3102.      line).
  3103. `xt'
  3104.      Flag: Teleray 1061; several strange characteristics.
  3105.  
  3106.